Aleš Sýkora wrote

Child posts menu for custom post type parent item

1. 2. 2021 in

This code will help you display menu of childs on current post. For example:

Product 1 = parent has those child pages:

– Product usage
– How to
– Disclaimer
– Calculator

When you put this child items menu in your template, it will show all childs of product 1 on all child pages and also on product 1 parent page.

global $post;
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&post_type=nabidka");
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&post_type=nabidka");
if ($children) { ?>
    <ul id="child-menu">
    <?php echo $children; ?>
<?php }

So you can build layouts like this:

(P= Parent page, CH = child)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More from category
Aleš Sýkora wrote
Oxygen’s Number Counter tricks – Dynamic data, speed and more
14. 7. 2021 in ,
All tips should be working for both Number Counter composite element and Circle Number Counter composite element in Oxygen Builder for WordPress. Using Dynamic Data in Number Counter Using the Number Counter from Oxygen Builder’s composite elements is cool until you need to use the dynamic data. When you add dynamic data source, span is […]
Read More
Aleš Sýkora wrote
WP Rocket + Toolset Exclude files from Defer JS
6. 11. 2019 in
If you use WP Rocket + Toolset (especially Toolset forms) you should exclude deferring some scripts.
Read More
Aleš Sýkora wrote
Comments Shortcode for Content Templates
11. 11. 2019 in
Display comments section whetever you want.
Read More
magnifiercross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram