0

Trying to display a category by an odd sequence and have the following:

<?php wp_list_categories('orderby=id&include=4,5,6,7,8,9,10,72,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41'); ?>

notice after ID #10 it jumps to ID #72. How can I code this better?

Note: Names are not alphabetical and numbers are not sequential, so just need to display IDs #4 to #10, #72, #11 to #41 listed in that order.

Respectfully, jw

3 Answers 3

1

You could do something like this:

<ul>
<?php
wp_list_categories('order_by=ID&title_li=&include=4,5,6,7,8,9,10');
wp_list_categories('order_by=ID&title_li=$include=72');
wp_list_categories('order_by=ID&title_li=&include=11,12,13,14,15,16,17, 18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41');
?>
</ul>

Just listing them in order for the include arg won't help you since that only goes into the WHERE clause, not into the ORDER BY clause of the SQL query.

1
  • Well, I feel stupid. I thought I had tried that a few hours ago, thank you wyrfel, it certainly worked. :)
    – user3376
    Commented Feb 22, 2011 at 3:52
0

I've not used it, but you may be interested in the My Category plugin.

2
  • Thank you, I will look into it but I am more interested in a programmatic solution this time. :)
    – user3376
    Commented Feb 22, 2011 at 0:35
  • I just tried the plugin and it didn't work...I also tried the Category Order plugin and that was not what I needed either.
    – user3376
    Commented Feb 22, 2011 at 3:40
0

Easy, if i understood a little bit (of your question) right...

$args_include = array(4,5,6,7,8,9,10,72,11,12,13,14,15,16,17, 18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41)';
$args_include = sort( $args_include, SORT_NUMERIC);

wp_list_categories( 'orderby=id&include='.$args_include );

...but i guess i haven't. So, what have the includes in common? And what "Note: Names are not alphabetical and numbers are not sequential" does that mean? I can't see any names, only IDs.

1
  • Thank you for your time kaiser. What I meant is I can't seem to order by title since the title names would not provide the correct sequence. I tried wp_list_categories('orderby=id&title_li=&include=4...72...41'); which placed 72 last. So, I was hoping there was a way to order by a range, like [4-10,72,11-41] or something similar.
    – user3376
    Commented Feb 22, 2011 at 1:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.