Problem:
How can I check in a View, if the posts in the Loop have parents, or specific parent fields exist?
Solution:
You can check if Parent Fields exist, or you could check if the Hidden "Parent ID" Field of your Post holds an ID (checks if parent exists)
For this to work, you must first enable the Hidden Field
_wpcf_bleongs_parent-post-type-slug_id
in Toolset > Settings > Front End Content > Hidden custom fields
Then, you can construct your Conditional HTML with the GUI "Conditional Display" in your View.
This would look similar to this code:
[wpv-conditional if="( '[wpv-post-field name='_wpcf_bleongs_parent-post-type-slug_id']' ne '' )"]SOMETHING[/wpv-conditional]
If you want to check single Fields only, you can do the same, but of course, you would choose to compare another particular Field.
Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-types-fields-and-custom-fields/
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/
https://toolset.com/forums/topic/conditional-output-with-post-relations/#post-402476
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | - | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 |
- | - | - | - | - | - | - |
Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)
This topic contains 2 replies, has 2 voices.
Last updated by Mr. DJ 7 years, 10 months ago.
Assisted by: Beda.