Hello
I have layout for a CPT 'Person' and on that layout I have 4 different views
VIEW 1
VIEW 2
VIEW 3
VIEW 4
The Person has 4 custom fields:
CHILD
PET
CASH GIFT
POSSESSION
and only one of these fields will be set to 'Yes' ..the others will default to 'No'
What I want to achieve is to display only one view on the layout depending on which Custom Field is set to 'Yes'
So for example
If CHILD = 'Yes' then
VIEW 1 - Display
VIEW 2 - Do not display
VIEW 3 - Do not display
VIEW 4 - Do not display
and if PET = 'Yes' then:
VIEW 1 - Do not display
VIEW 2 - Display
VIEW 3 - Do not display
VIEW 4 - Do not display
etc... Hope this makes sense...
Best wishes
Geoff
Dear Geoff,
I think it is possible with Views shortcode [wpv-conditional], you can try to follow our document to setup the conditions according to your requirements:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
If you need assistance for it, please provide a test site with the same problem, fill below private message box with login details, also point out the problem page URLs, I can setup a demo for you. thanks
Hi Luo
The conditional output only works with each list inside the view, I need to only display one view template out of four depending on field data in the current post...I have attached a diagram to help explain. The diagram shows 4 page scenarios with 4 different CPT 'People'. Each page displays a different person and each person has some custom fields switched to either 'Yes' or 'No'.. There are also 4 different views on the template page and only one can be visible depending on the custom fields of the current page post...
Please can you tell me how to achieve this...many thanks
Best wishes
Geoff
The [wpv-conditional] shortcode works in single "Person" post too.
You can use it to setup complicated conditions on custom fields., see our document:
Checking Types Fields and Custom Fields
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-types-fields-and-custom-fields/
Hi Luo
I've looked at all the help guides and can't find a way to do it which is why I really need your help!
As pointed out in the diagram I need to view or hide an entire view within a layout based on the fields of the person on the page...
Best wishes
Geoff
As I mentioned above, I can setup a demo for you.
https://toolset.com/forums/topic/conditional-output-in-a-layout/#post-1256519
Or you can provide your website database dump file in below private message box, I can test it in my localhost, thanks
Don't forget to point out the problem page URL
Thanks for the details, I can log into your website.
I assume we are talking about the layout "Layout For People":
hidden link
You can add a visual editor cell, click the "Conditional output" button, and setup the wpv-conditional shortcode, like this:
[wpv-conditional if="( $(child) eq 'Yes' )"]
VIEW NUMBER 1
[/wpv-conditional]
See screenshot Conditional-output.JPG, I have setup a demo in row 5, for your reference.
Please let me know if you need assistance to setup other shortcodes.
My issue is resolved now. Thank you!