Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9167065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:17:59+00:00 2026-06-17T15:17:59+00:00

I have in my WordPress theme, a section where I am getting child pages

  • 0

I have in my WordPress theme, a section where I am getting child pages to display their information. This is what I have right now:

<?php 
                $my_wp_query = new WP_Query();
                $all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));

                $staff = get_page_children(8, $all_wp_pages);

                foreach($staff as $s){
                    $page = $s->ID;
                    $page_data = get_page($page);
                    $content = $page_data->post_content;
                    $content = apply_filters('the_content',$content);
                    $content = str_replace(']]>', ']]>', $content);
                    echo '<div class="row-fluid"><span class="span4">'; 
                    echo get_the_post_thumbnail( $page ); 
                    echo '</span><span class="span8">'.$content.'</span></div>';
                } 
        ?>

I have five child pages that should be showing up, but only three are returning. I used print_r on $staff to see if the other pages were even in the array, but they aren’t. I’m not sure what the problem could be.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:18:00+00:00Added an answer on June 17, 2026 at 3:18 pm

    There is nothing wrong with get_page_children() or new WP_Query(). By default WP_Query returns only the last x number of pages created. It’s the limit imposed on WP_Query.

    get_page_children() simply takes the pages array returned by WP_Query and filters the children pages from that list. According to WordPress Codex: get_page_children “…does not make any SQL queries to get the children.”

    To fix the issue simply use:

        $query = new WP_Query( 'posts_per_page=-1' );
    

    Your code with the fix:

        <?php 
        $my_wp_query = new WP_Query();
        $all_wp_pages = $my_wp_query->query(array('post_type' => 'page', 'posts_per_page' => -1));
    
        $staff = get_page_children(8, $all_wp_pages);
    
        foreach($staff as $s){
            $page = $s->ID;
            $page_data = get_page($page);
            $content = $page_data->post_content;
            $content = apply_filters('the_content',$content);
            $content = str_replace(']]>', ']]>', $content);
            echo '<div class="row-fluid"><span class="span4">'; 
            echo get_the_post_thumbnail( $page ); 
            echo '</span><span class="span8">'.$content.'</span></div>';
        } 
        ?>
    

    Here is a helper function that you can call whenever you need to get page children

        function my_get_page_children( $page_id, $post_type = 'page' ) {
            // Set up the objects needed
            $custom_wp_query = new WP_Query();
            $all_wp_pages    = $custom_wp_query->query( array( 'post_type' => $post_type, 'posts_per_page' => -1 ) );
    
            // Filter through all pages and find specified page's children
            $page_children = get_page_children( $page_id, $all_wp_pages );
    
            return $page_children;
        }
    

    Example

    You code with with the helper function

        foreach(my_get_page_children(8) as $s){
            $page = $s->ID;
            $page_data = get_page($page);
            $content = $page_data->post_content;
            $content = apply_filters('the_content',$content);
            $content = str_replace(']]>', ']]>', $content);
            echo '<div class="row-fluid"><span class="span4">'; 
            echo get_the_post_thumbnail( $page ); 
            echo '</span><span class="span8">'.$content.'</span></div>';
        } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is function.php of a wordpress theme that NOD32 says this code have a
I have installed prettyprint in my Wordpress theme. Now in order to use it,
I have a wordpress theme that has a build in shortcode for creating an
I have a wordpress theme that I like to duplicate. To make things easier
I have a Wordpress theme that uses MooTools and jQuery. I use jQuery noConflict
I am using the WordPress theme Studio8 and I have create some custom forms
I am modifying a wordpress theme completely, and have run into one very simple
i'm building a wordpress webpage based on the Skeleton Wordpress theme. I have 2
i have made a simple php contact form following this tutorial: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme The big
I have a Wordpress Front End Form to Publish/Draft Posts directly from my theme:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.