Problem:
Trying to create a page that Lists only the parent posts that actually have Children, not all the parent posts.
Solution:
1. Add this code in your theme’s or child theme’s functions.php file:
function child_exists_func( $atts ){ extract( shortcode_atts( array( 'child_post_type_slug' => '', ), $atts ) ); $child_posts = types_child_posts($child_post_type_slug); if ($child_posts) { return true; } } add_shortcode( 'child-exists', 'child_exists_func' );
2. Register the ‘child-exists’ shortcode first in Toolset >> Settings >> Front-end Content >> Third-party shortcode arguments.
3. Then add this shortcode in your View >> Loop Output Editor:
[wpv-conditional if="( '[child-exists child_post_type_slug=belong]' eq '1' )"] [wpv-post-link] [/wpv-conditional]
==> Where as “belong” is your child post type slug that you should replace.
Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | - |
- | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | - |
Supporter timezone: Asia/Karachi (GMT+05:00)
This topic contains 15 replies, has 3 voices.
Last updated by 7 years, 3 months ago.
Assisted by: Noman.
The forum ‘Types Community Support’ is closed to new topics and replies.