I have the following code in my sidebar to list all the taxonomy categories.
<div class="left">
<h1>Categories</h1>
<?php
//list terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin)
$taxonomy = 'workcategories';
$orderby = 'name';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$title = '';
$args = array(
'taxonomy' => $taxonomy,
'orderby' => $orderby,
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
'title_li' => $title
);
?>
<ul>
<?php wp_list_categories( $args ); ?>
</ul>
</div><!-- # END left -->
And this code outputs them in alphabetical order. Is there a way that I can order them however I like? My client wants them in a certain order and I have no idea how to do this.
Many thanks
E
By what criterion do you need to order your taxonomy terms?
See this argument-array key:
Per the documentation for
wp_list_categories()
, theorderby
parameter can take the following values:'ID'
– Default'name'
'slug'
'count'
'term_group'
Note, you may also want to add the
order
parameter:This parameter takes:
'ASC'
'DESC'
EDIT
Using your code:
Um, that doesn’t make sense. IDs are numerical, because they are integers. Thus, ordering by
ID
results in an ascending or descending list of IDs, in numerical order.You can’t impose a manual ordering of categories natively in WordPress.
The great thing about WordPress is that it has a huge developer community behind it. A quick search gave me this plugin that pretty much gives you exactly the feature you are looking for.