sort by "include" id's for get_pages

  1. shazdeh

    I'm using get_pages function to create a list of pages and passing an array of ordered page ID's for "include" parameter, but WP does not respect the order of the array. I was expecting this to be default behavior of WP.
    Could an option be added to this function so WP would output pages by the order you give it for the include option?

    Posted: 3 years ago #
  2. Ipstenu (Mika Epstein)

    http://codex.wordpress.org/Function_Reference/wp_list_pages may be what you want instead.

    Posted: 3 years ago #
  3. shazdeh

    wp_list_pages does not support that either.

    To make it work I used a for loop and used "get_page($id)" function for each of the pages to ensure they show up in the right order.

    When you do a query like this:
    $pages = get_pages( array( 'include' => array( 10, 2, 5 ) ) );
    shouldn't it return an array of pages where "10" ID comes first and 2 comes after that, and the pages with the 5 ID would be the last?

    Posted: 3 years ago #
  4. Ipstenu (Mika Epstein)

    No, that just says 'Get pages 10, 2, and 5', it doesn't force the order.

    Posted: 3 years ago #

RSS feed for this topic


You must log in to post.

  • Rating

    0 Votes
  • Status

    This idea has been implemented