Add Parent to List of Subpages

If I understand what you want, it is trickier than it should be to get it working. $ancestors = array(); $ancestors = get_ancestors($post->ID,’page’); $parent = (!empty($ancestors)) ? array_pop($ancestors) : $post->ID; if (!empty($parent)) { $pages = get_pages(array(‘child_of’=>$parent)); if (!empty($pages)) { $page_ids = array(); foreach ($pages as $page) { $page_ids[] = $page->ID; } $children = wp_list_pages(“include=”.$parent.’,’.implode(‘,’,$page_ids).”&echo=1″); echo … Read more

How can I list all pages with their templates?

https://codex.wordpress.org/Function_Reference/get_page_template_slug a basic query to get all pages, sorted by title, then output page title and template file name: $args = array( ‘post_type’ => array( ‘page’ ), ‘order’ => ‘ASC’, ‘orderby’ => ‘title’ ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); echo ‘<p>’; the_title(); echo … Read more

How to List All Pages (With their template names) Within a Website

Not so hard as you expected. Try this: global $wpdb; $sql = “SELECT post_title, meta_value FROM $wpdb->posts a JOIN $wpdb->postmeta b ON a.ID = b.post_id WHERE a.post_type=”page” AND a.post_status=”publish” AND b.meta_key = ‘_wp_page_template’ “; $pages = $wpdb->get_results($sql); echo ‘<pre>’; print_r($pages); echo ‘</pre>’;

How does wordpress calculate the page depth?

Ok, lets break it down, all the links are going to be to the source code. wp_list_pages() only uses get_pages() to (sic!) get pages, walk_page_tree() does the hierarchical structuring inside it. The further course of the process goes Walker_Page – and the generic Walker of course -, unless a custom walker is used. Inside walk_page_tree() … Read more

How to hook wp_list_pages?

A quick Google Search came up with this Source Try the following: function wp_list_pages_filter($output) { // modify $output here, it’s a string of <li>’s by the looks of source return $output; } add_filter(‘wp_list_pages’, ‘wp_list_pages_filter’);

Highlighting current item of custom post types’ sub pages, listed by wp_list_pages

The problem with this code is that the query is being altered and current_page_item is being lost. This is the part causing problems. $post = get_post( $getid ); setup_postdata( $post ); If you comment out those two lines you’ll see that current_page_item appears. There are also some secondary problems with this code that have no … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)