WordPress.org

Ready to get started?Download WordPress

Ideas

sort by "include" id's for get_pages

  1. shazdeh
    Member

    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: 2 years ago #
  2. Ipstenu (Mika Epstein)
    Half-Elf Support Rogue & Mod

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

    Posted: 2 years ago #
  3. shazdeh
    Member

    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: 2 years ago #
  4. Ipstenu (Mika Epstein)
    Half-Elf Support Rogue & Mod

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

    Posted: 2 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    0 Votes
  • Status

    This idea has been implemented