How to get a list of all recently published child pages?

This will get you the post data for all child pages: $args = array( ‘post_type’ => ‘page’, ‘post_parent__not_in’ => array(0), ‘no_found_rows’ => true, ); $child = new WP_Query($args); var_dump(wp_list_pluck($child->posts,’post_title’)); // debugging only Then pass the IDs to wp_list_pages(): $args = array( ‘post_type’ => ‘page’, ‘post_parent__not_in’ => array(0), ‘no_found_rows’ => true, ); $child = new WP_Query($args); … Read more

No link on empty page in wp_list_pages

wp_list_pages() uses a walker named Walker_Page to render its output and this can be overridden. Below is a customized version of Walker_Page::start_el(). The code was first copied from the core, then a simple check was added before outputting the link. If a post does not have any content, then the title is wrapped in a … Read more

Check whether the child page has siblings

Of course it is possible. Just take a look at docs for wp_list_pages So something like this will do the trick: <?php global $post; // assuming there is global $post already set in your context wp_list_pages( array( ‘exclude’ => $post->ID, // exclude current post ‘parent’ => $post->post_parent // get only children of parent of current … Read more

create shortcode to show children if any otherwise siblings

Yes, you’re close. What you want is something like this: function rt_list_children() { global $post; $output=””; if ( $post->post_parent ) { // if it’s a child page $siblings = wp_list_pages( array( ‘child_of’ => $post->post_parent, ‘title_li’ => ”, ‘echo’ => ‘0’, ) ); if ( $siblings ) { // it has siblings $children = $siblings; } … Read more

Adding span tags within wp_list_pages list items

There is more than one way to accomplish this in WordPress. Option 1: Using the link_before parameter with wp_list_pages. $childpages = wp_list_pages( array( ‘sort_column’ => ‘menu_order’, ‘title_li’ => ”, ‘child_of’ => $parent_id, ‘echo’ => 0, ‘link_before’ => ‘<span class=”fa-li”><i class=”fas fa-spinner fa-pulse”></i></span>’ ) ); Option 2: Create a custom walker, then add the walker parameter … Read more

Exclude pages with certain template from wp_list_pages

Daniel, exclude parameter doesn’t accept array. Use your code this way: $exclude = []; foreach(get_pages([‘meta_key’ => ‘_wp_page_template’, ‘meta_value’ => ‘page-templates/page-noindex.php’]) as $page) { $exclude[] = $page->post_id; } $args = array( ‘exclude’ => implode(“,”, $exclude), ‘title_li’ => ”, ‘sort_column’ => ‘menu_order, post_title’, ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’ ); wp_list_pages($args); I think you can refactor it … Read more

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