0

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

Usage:

<?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?

3
  • 1
    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. Nov 25, 2011 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, 2011 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. Nov 25, 2011 at 17:22

1 Answer 1

1

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.

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.