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

I have this function which gives me IDs and titles of all child pages of a given parent ID.

function getPageChildren($page_id) {

  $my_wp_query = new WP_Query();
  $all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));

  $page_children = get_page_children($page_id, $all_wp_pages);

  foreach ($page_children as $p) {    
    $tmp['id'] = $p->ID;
    $tmp['title'] = $p->post_title;    
    $pages[] = $tmp;

  return $pages;    

I want some way of ordering them in the backend, which I'd presume is done in the page attributes box of the edit page in the Order field?

I have amended my the second statement in the above with the following:

$all_wp_pages = $my_wp_query->query(array('post_type' => 'page', 'sort_order' => 'ASC', 'sort_column' => 'menu_order'));

hoping this would tell the function to talke into account the order I specify, but this doesn't seem to work.

Can anyone tell me how I am supposed to order the results of my function from the backend please?


share|improve this question
up vote 1 down vote accepted

sort_column is not a valid parameter for WP_Query. You want orderby. sort_order is also not a valid parameter. It should just be order.

$all_wp_pages = $my_wp_query->query(
        'post_type' => 'page', 
        'order' => 'ASC', 
        'orderby' => 'menu_order'

The Codex is your friend.

share|improve this answer
thanks.......... – Larry B Jan 13 '13 at 16:37

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.