wp_list_pages loses its place when I add posts to a page
-
I am currently using the following code to dynamically list parent and child pages of a given section of a website:
<?php if($post->post_parent) { $parent_link = get_permalink($post->post_parent); ?> <?php $parent_title = get_the_title($post->post_parent); echo $parent_title; ?> <?php } else { ?> <?php $parent_title = get_the_title($post->post_parent); echo $parent_title; ?> <?php } ?> </p> <?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 works great. You can see an example of it working properly here: https://rnche.com/ostc/education/youth-education/
However, I have created some Custom Post Types to display events, and when I call these events in the main content area of a template that uses the same code above for the sidebar, the page seems to forget where it’s at. It displays the title of the first event, and only that, instead.
Here is the incorrect nav: https://rnche.com/ostc/on-stage/2013-season/
And a page in the same category that displays the left-nav properly (because it’s not calling any event posts in the main content area): https://rnche.com/ostc/on-stage/2012-season/
I can’t figure out why the page doesn’t know where it is now that I’ve added posts. Help?
Thanks in advance,
Dave
- The topic ‘wp_list_pages loses its place when I add posts to a page’ is closed to new replies.