The following example shows how to query posts that have a custom filed name color
and the assigned value is red
.
1 |
$red_pages = query_posts('post_type=page&meta_key=color&meta_value=red&orderby=menu_order&order=ASC'); |
The following example shows how to query posts that have a custom filed name color
and the assigned value is red
.
1 |
$red_pages = query_posts('post_type=page&meta_key=color&meta_value=red&orderby=menu_order&order=ASC'); |
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).
1 2 3 4 5 6 7 8 9 |
$params = array( 'post_type'=>'page', 'post_parent'=>'123', 'depth'=>'1', 'orderby'=>'menu_order', 'order'=>'ASC' ); $pages = query_posts($params); print_r($pages, 'ARRAY_A'); |