I have this problem that I am encountering. I am trying to sort my categories to display in the order that I want them to. I have read the WordPress documentation on all of the sort options. However, there is no inclination of how to choose the categories and make them flow the way I want.
This is what the Codex presents:
orderby (string) Sort categories alphabetically or by unique category ID. The default is sort by Category ID. Valid values:
- id
- name - default
- slug
- count
- term_grouporder (string) Sort order for categories (either ascending or descending). The default is ascending. Valid values:
- asc - default
- desc
However, like I said, this does not help me because I need them to display in the order I choose.
Here is the code I am implementing at the moment. Which is in the order that I want them to display.
<?php
$args = array(
'orderby' => 'ID',
'order' => 'ASC',
'include' => '5,6,7,8,29,9,10,11,12,13,14,15,16'
);
$categories = get_categories($args);
foreach($categories as $category) {
echo '<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name . '</a>' . ' ' . '(' . $category->count . ')' . '</li> ';
}
?>