kurtvonn
Member
Posted 5 years ago #
In my sidebar i have a list of sub-pages. For example on the ABOUT page, it lists the sub pages for ABOUT with no problem. I'm using this code in the sidebar:
<?php if(wp_list_pages("child_of=".$post->ID."&echo=0")) { ?>
<?PHP wp_list_pages("title_li=&child_of=".$post->ID."&show_date=modified&date_format=$date_format&"); ?>
<?php } ?>
However, if i click on one of the sub page titles, it takes me to the sub page, but then i lose the sub page titles on the side bar. Also the Page titles I am displaying as a Nav bar in the header.php file. no problems there.
Has anyone experienced this before?
oliviameiring
Member
Posted 5 years ago #
I'm having the same problem - subpage links not displaying at all when Im on a subpage. Perhaps because the code only displays child pages of the current page.
I can fix this problem by hardcoding the Post ID, since I'm using a different template for each section, but there must be a more elegant solution.
oliviameiring
Member
Posted 5 years ago #
Here you go, this also displays the submenu when you're on a child page:
<ul>
<?php if(get_the_title($post->post_parent) != the_title(' ' , ' ',false)) {
wp_list_pages("child_of=".$post->post_parent."&sort_column=menu_order&title_li=");
} else {
wp_list_pages("child_of=".$post->ID."&sort_column=menu_order&title_li=");
}
?>
</ul>