Displaying only the direct children of a parent page ( sidebar nav list)
-
Here is my code:
<?php if($post->post_parent) { $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); } else { $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); } if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?>
This outputs children and grandchildren links. I want to only display the direct children for a particular page, which I will wrap in a conditional. So what I need to do is tell it not to display the grandchildren. I hope this makes sense.
Anyone have the expertise to figure this out? I’ve had trouble searching for this online.
Thanks!
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Displaying only the direct children of a parent page ( sidebar nav list)’ is closed to new replies.