Problem:
Display post link if it has parent.
Solution:
Using [wpv-conditional] shortcode we can check if post has a parent.
When using Types posts relationships, the parent of a given type is stored in a field:
_wpcf_belongs_{parent-slug}_id
Let’s assume that we are displaying a Car post type that has a Maker as a parent post type. Each Car will store its Maker id in the field _wpcf_belongs_maker_id, and you can check if a Car has a Maker using this code:
For example:
[wpv-conditional if="((empty($(_wpcf_belongs_maker_id))))"] This car has no maker [/wpv-conditional]
Where:
_wpcf_belongs_{parent-slug}_id = replace your post slug with "{parent-slug}".
Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
[Section: "Checking If A Parent Exists"]
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
This topic contains 2 réponses, has 2 voix.
Last updated by Shreyas Khatri Il y a 8 années et 3 mois.
Assisted by: Minesh.