Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#21681 closed feature request (wontfix)

Add "order" parameter for get_taxonomies()

Reported by: acsnaterse's profile acsnaterse Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4.1
Component: Taxonomy Keywords:
Focuses: Cc:

Description

When retrieving all the taxonomies with get_taxonomies() you will just receive a bunch of taxonomies in arbitrary order.

Would be very nice if there would come a way to order all these taxonomies. By name, custom order or anything else which would make sense. Especially the custom order would be great.

No ideas for now on how to implement it, but I think a feature like this would make a lot of sense.

Change History (1)

#1 @scribu
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

You need to keep in mind that get_taxonomies() just filters a PHP array; there's no SQL involved.

So, if you want a custom order, just do this:

$taxonomy_names = array( 'taxonomy_b', 'taxonomy_a', ... );

$taxonomy_objects = array();
foreach ( $taxonomy_names as $tax_name ) {
  $taxonomy_objects[] = get_taxonomy( $tax_name );
}

For ordering by title, you can use usort() and so forth; it's just PHP.

And, since there isn't a clear and common use-case for this, I don't think it would be useful to have in Core.

Note: See TracTickets for help on using tickets.