I'd like to get all pages that are direct children of HOME_ID. Per http://codex.wordpress.org/Function_Reference/get_pages#Parameters (see 'parent' parameter), I think this should be done with get_pages:

$top_pages = get_pages(array('parent' => HOME_ID, 'sort_column' => 'menu_order'));

but this returns no results. I get results back if I plug in 0 for HOME_ID. No sweat because I can achieve what I want with:

$menu_wp_query = new WP_Query();
$top_pages = $menu_wp_query->query(array('post_type' => 'page', 'post_parent' => HOME_ID, 'orderby' => 'menu_order'));

But still uncomfortable; is this a bug? Using WP 3.2.1 Thanks.

  • have u noticed that parent is an integer value? – andresmijares Dec 11 '11 at 7:47

Assuming that, by "HOME_ID", you are referring to the static Page used to display the Site Front Page, then you want to use get_option( 'front_page' ) to get the ID for this page:

$menu_wp_query_args = array(
    'post_type' => 'page', 
    'post_parent' => get_option( 'front_page' ), 
    'orderby' => 'menu_order'
$new_wp_query = new WP_Query( $new_wp_query_args );
| improve this answer | |

Assuming your homepage has title as 'Home'. Use this:


$home = get_page_by_title('Home');
$home_children = get_posts(array('post_type'=>'page', 'post_parent'=>$home->ID));

echo "<pre>";
echo "</pre>";    


Make sure you pass the exact title to the get_page_by_title function.

| improve this answer | |

in a custom template Page i use

query_posts(array( 'post_parent' => 6, 'post_type' => 'page'));

post_parent is selected by ID of the specific Page, in this case 6. ..at least it works for me. Hope that helps. cheers!

| improve this answer | |
  • Do not use query_posts() for secondary loop queries. – Chip Bennett Apr 12 '12 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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