List child pages of current page but limit to specific year

Due to wp_list_pages() leveraging get_pages() to actually retrieve the Page posts, and because get_pages() implements it’s own query logic independent of WP_Query‘s, it’s not possible to use arbitrary query variables which are not directly supported by get_pages(), including year, mothnum, day, date_query, etc. In order to continue using wp_list_pages() to this end, I think the … Read more

Show siblings (if any) and parents

As it stands your code almost works, but it checks to see if the current page has a parent, which will always be true for both 2nd and 3rd level pages. WordPress gives us get_ancestors to retrieve an ordered array of ancestors for any hierarchical object type: get_ancestors( $object_id, $object_type ); So we can use … Read more

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

Given the page id, check if it has children

The example from the WP codex for get_page_children does what you are looking for with a page titled “Portfolio”: $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array(‘post_type’ => ‘page’, ‘posts_per_page’ => ‘-1’)); // Get the page as an Object $portfolio = get_page_by_title(‘Portfolio’); // Filter through all pages and find Portfolio’s children $portfolio_children = get_page_children( $portfolio->ID, $all_wp_pages … Read more

how to properly list child pages in sidebar?

Here is the code that satisfies all your 3 requirements above. <?php /* * get_page_depth * Gets the page depth, calls get_post on every iteration * https://gist.github.com/1039575 */ if ( !function_exists( ‘get_page_depth’ ) ) { function get_page_depth( $id=0, $depth=0 ) { global $post; if ( $id == 0 ) $id = $post->ID; $page = get_post( … Read more