Tag Info

New answers tagged


You'll have to use this function get_queried_object_id(), if the ID returned by this function is equal to the ID of the page ($page->ID in your code), that's the current page. Based on that you can add a class.


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( ...


Try this code snippets once: $args = array('post_type' => 'page', 'parent' => 0); $parent_pages = get_pages($args); if( $parent_pages ){ echo '<ul>' . "\n"; foreach( $parent_pages as $page){ $children = wp_list_pages("title_li=&child_of=".$page->ID."&echo=0"); if( $children ) { echo '<li><a ...


If you want this for pages only, which would makes sense as to what you described this, just wrap the whole bunch of code in if ( is_page() ) { ... }. If you were to put this into a function, you could just bail out early. function wpdev_156446_list_parent_page_tree() { if ( ! is_page() ) { return; } // Your above code here } // ...

Top 50 recent answers are included