Show the grandmother/father of the childpage

You need to look at get_ancestors() to get the top level parent of a page. Just a note, for reliability, use get_queried_object() (or even better $GLOBALS[‘wp_the_query’]->get_queried_object()) to get the current post/page object on singular pages, $post can be quite unreliable You can try the following in your shortcode: $post = $GLOBALS[‘wp_the_query’]->get_queried_object(); // Make sure the … Read more

Display the latest content from subpages of another page

you can use the number param to limit the number of pages you want and get the custom field in the foreach loop 🙂 (child of = your parent page, or the current page) $mypages = get_pages( array( ‘child_of’ => $post->ID, ‘sort_column’ => ‘post_date’, ‘sort_order’ => ‘desc’, ‘number’ => 3, ) ); foreach( $mypages as … Read more

Display Tags of Child Pages

I modified my code based on this posting’s answer, and the page displays everything I want now. <div id=”masonry-loop” class = “group”> <?php global $post; $child_pages_query_args = array( ‘post_type’ => ‘page’, ‘post_parent’ => $post->ID, ); $child_pages = new WP_Query( $child_pages_query_args ); if ( $child_pages->have_posts() ) : while ( $child_pages->have_posts() ) : $child_pages->the_post(); ?> <?php $images … Read more

Listing Child Pages in Random order

The sort_column parameter of wp_list_pages() does allow items to be returned in random order using the rand option. sort_column (string) Comma-separated list of column names to sort the pages by. Accepts ‘post_author’, ‘post_date’, ‘post_title’, ‘post_name’, ‘post_modified’, ‘post_modified_gmt’, ‘menu_order’, ‘post_parent’, ‘ID’, ‘rand’, or ‘comment_count’. Default ‘post_title’. add_shortcode( ‘wpb_childpages’, ‘wpb_list_child_pages’ ); function wpb_list_child_pages() { global $post; if … Read more

List child pages, exclude the current page

Looks like a syntax error to me. Try: wp_list_pages(“title_li=&child_of=2143&exclude=$current_post_id”) OR wp_list_pages(“title_li=&child_of=2143&exclude=”.$current_post_id) Also I will suggest to pass parameters as array instead of a string, for better debugging. wp_list_pages( array( ‘child_of’ => 2143, ‘exclude’ => array( $current_post_id ), ); Make sure $current_post_id is giving proper value.

Display child pages full template including the content

I would try setting up post data in the loop and then calling a page template using get_template_part function. Note: depending on theme it may produce some unexpected results, as page template sometimes also includes site header and footer. But it’s something to get you started. $getchilds = array( ‘parent’ => $post->ID, ‘child_of’ => $post->ID, … Read more