Tag Archives: subpage

Is it a subpage of the page id 129?

So in your functions.php file:
**
 * Check whether we are on a subpage
 *
 * @return mixed ID of the parent post or false if this is not a subpage.
 */
function wpdocs_is_subpage() {
    // Load details about this page.
    $post = get_post();
 
    // test to see if the page has a parent
    if ( is_page() && $post->post_parent ) {
        // Return the ID of the parent post.
       return $post->post_parent;
    // There is no parent so ...
    } else {
        // ... The answer to the question is false
          return false;
    }
   
}

 
And in your page.php or where ever:

 

 
Source

Get subpages’ title and content

 'page',
    'posts_per_page' => -1,
    'post_parent'    => $post->ID,
    'order'          => 'ASC',
    'orderby'        => 'menu_order'
 );


$parent = new WP_Query( $args );

if ( $parent->have_posts() ) : ?>

    
    have_posts() ) : $parent->the_post(); ?>