WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From the Codex, I'm using this function to return all children from a page ID without using SQL queries.


<?php get_page_children( $page_id, $pages ) ?>

$page is defined as a "List of pages' objects".

What are examples of page objects I would use in this case?

share|improve this question
What are you trying achieve in the end? I assume you just want to get the children of a specific page. If yes, then there are other simple methods for it. As far as I understand the codex entry, it could be page, post or custom_post_type. – Rutwick Gangurde Nov 25 '11 at 15:50
I thought page and post were all part of the same $post object where page would be defined as $post->post_type='page' – AlxVallejo Nov 25 '11 at 16:33
All of them are the same objects, if you do a global $post; print_r($post) on any page, you'll see it as a post object. But the type is what differentiates them. – Rutwick Gangurde Nov 25 '11 at 17:22
up vote 1 down vote accepted

They give you an example on that page by using WP_Query to query for all pages, then get_page_children just filters that list. the "without using SQL queries" part is a bit of a misnomer, since you have to have already queried the database at some point to get those pages. if you don't already have a result to filter, then something like get_children or get_pages might be simpler.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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