active parent page when clicked on childpage
http://codex.wordpress.org/Function_Reference/wp_list_pages#Markup_and_styling_of_page_items style .current_page_parent and/or .current_page_ancestor the same as .current_page_item
http://codex.wordpress.org/Function_Reference/wp_list_pages#Markup_and_styling_of_page_items style .current_page_parent and/or .current_page_ancestor the same as .current_page_item
<?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.
<?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
To list all page title and id, you can try this code! $page_ids= get_all_page_ids(); echo ‘<h3>My Page List :</h3>’; foreach($page_ids as $id) { echo ‘<br />’.get_the_title($id).’ ‘ .$id; } click here for more info
Just pass number=5 and it should work since wp_list_pages() uses get_pages() which has number parameter, and also if you look at wp_list_pages codex entry at the bottom under change log you can see that it take the number parameter since version 2.8
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
Change the depth parameter to how many levels you want the walker to traverse. From the docs depth parameter description. Number of levels in the hierarchy of pages to include in the generated list. Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to the given n depth). Default 0. … Read more
figured it out – in case anyone else stumbles upon this with a similar question: The proper walker to extend is Walker_Page, not Walker_Nav_Menu. Walker_page is located in /wp-includes/post-template.php (line 978).
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
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