Get children menu items of a custom menu item
-
I am using a snippet to display the children pages in a sidebar of a page. Here is the snippet I am using.
<?php if ($post->post_parent) { $ancestors=get_post_ancestors($post->ID); $root = count($ancestors)-1; $parent = $ancestors[$root]; } else { $parent = $post->ID; } print '<h2><a href="'.get_permalink($parent).'">'.get_the_title($parent).'</a></h2>'; $children = wp_list_pages("title_li=&child_of=". $parent ."&echo=0&depth=1"); if ($children) : ?> <ul> <?php echo $children; ?> </ul> <?php endif; ?>
This snippet works great for pages that are actually part of the WordPress. But when using it when the top parent is a custom menu item (Place Holder) it only grabs the top parent title and not the menu items under it.
I’m extremely familiar with WordPress and I am hoping I am not having a blonde moment here ( No offensive attended).
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Get children menu items of a custom menu item’ is closed to new replies.