Add Parent to Subpage List

<?php if($post->post_parent){ $children = wp_list_pages(“title_li=&include=”.$post->post_parent.”&echo=0″); $children .= wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0″); } else { $children = wp_list_pages(“title_li=&include=”.$post->ID.”&echo=0″); $children .= wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″); } if ($children) { ?> <ul class=”subpages”> <?php echo $children; ?> </ul> <?php } ?> Try that. Just have to include the parent much like you do on the child pages, but using the current $post-ID.

Hide Parent if No Children

<?php if ($post->post_parent) { //We are a child, print out sub menu wp_list_pages( array(‘title_li’=>”,’include’=>$post->post_parent) ); wp_list_pages( array(‘title_li’=>”,’depth’=>1,’child_of’=>$post->post_parent) ); } //We are not a child but do we have children $children = wp_list_pages(array(‘child_of’ => $post->ID, ‘echo’ => 0)); if ( !empty($children) ) { //If so print out the sub menu wp_list_pages( array(‘title_li’=>”,’include’=>$post->ID) ); wp_list_pages( array(‘title_li’=>”,’depth’=>1,’child_of’=>$post->ID) ); … Read more

List subpage of subpage

Here is a function that im using for submenus, maybe there is a better way to do this but i always ends up with this solution. Add this function to your theme functions.php file: function wpse_submenu( $id, $echo = false, $showParent = true, $depth = 0 ) { global $wpdb, $post, $before, $page_for_posts; // if … Read more

List all Posts under heading in wp_list_pages menu

You’ve got the right idea, however; Don’t use query_posts, use get_posts instead Using the wp_list_pages filter will just add the list at the end Using template tags like the_permalink() will echo the output, so you can’t use it in string concatenation You’ll need to use a custom walker (the family of classes for generating hierarchical … Read more

Change Parent Name with wp_list_pages?

You could of course use some preg_replace() tricks to solve this, but here’s a little (untested) idea using the the_title filter instead: add_filter( ‘the_title’, ‘wpse_title’ ); $children = wp_list_pages(“title_li=&include=”.$post->post_parent.”&echo=0″); where our filter callback is: function wpse_title( $title ) { remove_filter( current_filter(), __FUNCTION__ ); return __( ‘Overview’ ); } Remark 1: I think you should consider … Read more