• i’ve read all the docs, i’ve traced and grokked the php and i’m pretty sure it’s not possible, but-

    i’m using wp_list_pages with include e.g. wp_list_pages(“include=6,12,9,100,2”)

    i want the output order to be exactly as specified: 6,12,9,100,2

    the defaults for sort_column are ‘menu_order, post_title’ and the only way to override is sort it differently, not refrain from sorting at all.

    my workaround is to have five separate calls to wp_list_pages including each one separately, but that’s … ugly.

    many thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • wp_list_pages('sort_column =ID&sort_order=asc&include=6,12,9,100,2)

    Reposting as I had an space in there and forget the backticks…

    wp_list_pages('sort_column=ID&sort_order=asc&include=6,12,9,100,2)

    Thread Starter squaredesign

    (@squaredesign)

    tried that – that will sort the ID’s numerically – so it displays 2,6,9,12,100.

    i guess what i’m looking for is the ability to specify the sort_column parameter with no value, therefore it doesn’t try to sort at all.

    (if i use sort_column with no value the function returns nothing)

    I also had some pages that I wanted displayed in a certain order instead of by ID’s. My solution was to use <?php wp_list_pages('sort_column=menu_order&amp;title_li=&amp;include=1200,451,2768,154'); ?> and then I went to the edit page screen, made sure “Attributes” was checked under “Screen Options” and then ordered the pages in the number I wanted them in. Instead of numbering them 1 through 4, I used larger numbers (10, 20, 30, 40) so that it would be easy in the future to go back and stick a new page somewhere in the order by simply giving the new page a value like 11 or 22.

    It’s not perfect, but it works and allows me to display the pages in the order I want.

    At the very least, you could shorten your five separate calls to just three (call 6,12 then 9,100 then 2). I think that would work, right?

    Thread Starter squaredesign

    (@squaredesign)

    yep i thought of that, but i’ve got two separate nav areas; one is linear/hierarchical so i use menu-order for that one. this one is non-adjacent pages so there’s really no other logical way to do it.

    probably something that hasn’t been requested before. if i can get someones attention at automattic maybe in a future release we’ll have sort_column=include or something ??

    Don’t forget you can submit your idea here: https://www.ads-software.com/extend/ideas/

    Or submit a trac ticket and of course a patch would be welcome. See Reporting Bugs for info on submitting a trac ticket.

    @shyzer, funny I never thought of that. Thanks for the reminder. That worked like a charm

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘possible for wp_list_pages to sort by order specified in include= param?’ is closed to new replies.