Categories

Get page children

The following example requests pages whose parent is ID 123. By specifying depth as 1 we can make sure only inmediata children will be return. A list of all pages can be obtained if depth is set as zero (0).

$params = array(
    'post_type'=>'page',
    'post_parent'=>'123',
    'depth'=>'1',
    'orderby'=>'menu_order',
    'order'=>'ASC'
);
$pages = query_posts($params);
print_r($pages, 'ARRAY_A');

1 comment to Get page children

  • Thanks so much. I was having trouble using get_post_children() – it was only returning the first child value – but this worked like a charm and returned the full array.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

IMPORTANT! To be able to proceed, you need to solve the following simple math (so I know that you are a human) :-)

What is 5 + 13 ?
Please leave these two fields as-is: