This has been bugging the hell out of me, it should be so simple!

I have a list of child pages under the parent called 'Our Homes'. The sitemap structure is as follows:

  • Home
  • Our Homes
    • home 1
    • home 2
    • home 3

For each home I want to display the following:

  • Title
  • Content snippet
  • Image
  • Map
  • Link to the child page for that home

How do I loop through each child page under 'Our Homes' and display the specified content above from each on the home page?

1 Answer 1


To me, this sounds like a good use-case for a custom post type for homes, but, in any case, this is the basic concept you'd need to follow to get this working as you've got it set up now.

// Set up the objects needed
$homes_wp_query = new WP_Query();
$all_wp_pages = $homes_wp_query->query(array('post_type' => 'page', 'posts_per_page' => '-1'));

// Get the page as an Object
$our_homes =  get_page_by_title('Our Homes');

// Filter through all pages and find Our Homes' children
$home_children = get_page_children( $our_homes->ID, $all_wp_pages );

// echo what we get back from WP to the browser
echo '<pre>' . print_r( $home_children, true ) . '</pre>';

That will print the post objects, then you can pick and choose which elements (like title, etc.) that you want to echo out

  • You're absolutely right and now i'm kicking myself.
    – Amesey
    Jun 21, 2017 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.