Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#11162 closed enhancement (worksforme)

Order in wp_list_categories

Reported by: bi0xid's profile bi0xid Owned by:
Milestone: Priority: low
Severity: minor Version:
Component: General Keywords: list categories
Focuses: Cc:


Now, if you want a custom order when listing categories, you must write a list of calls to wp_list_categories() with different includes.

<?php wp_list_categories('show_count=0&title_li=&include=84'); ?>
<?php wp_list_categories('show_count=0&title_li=&include=23'); ?>
<?php wp_list_categories('show_count=0&title_li=&include=174'); ?>
<?php wp_list_categories('show_count=0&title_li=&include=175'); ?>

Maybe we could do a custom order which reads the include order:

<?php wp_list_categories('show_count=0&title_li=&orderby=include_order&include=84,23,174,175'); ?>

Change History (2)

#1 @scribu
15 years ago

  • Milestone 2.9 deleted
  • Resolution set to worksforme
  • Status changed from new to closed
  • Type changed from task (blessed) to enhancement
  • Version 2.9 deleted

Currently, passing a list of arguments to 'include' simply retrieves that set of categories, regardless of their hierarchy.

So here are the problems with your proposal:

1) What if I don't want to order by those IDs, just simply include them?

2) The hierarchy would be broken

Even if those problems were resolved, the implementation would still boil down to this:

  foreach ( array(84, 23, 174, 175) as $id )

#2 @bi0xid
15 years ago


1) Then you don't enter the orderby, and it will order by default (name).

2) Don't think so. It shows the categories included. If they have hierarchy activated, it can be shown too. But it's not compulsory. Yes, categories can repeat in some places, but the user can control it.

Thanks for the implementation. For people not very good with code I think we need to try to simplify the work. But if you think it's good like that, it's good for me too :)

Note: See TracTickets for help on using tickets.