”Category Order and Taxonomy Terms Order’ plugin’, order Categories and all custom taxonomies terms (hierarchically) using a Drag and Drop Sortable javascript capability.
When the condition arrives, where we want to order particular categories / taxonomies in the alphabetical order, then we can use the ksort. Check the example :
1 2 3 4 5 6 7 8 9 10 11 |
function sortCategories($items) { $placeHolder = []; foreach ($items as $item) { $placeHolder[$item->name]= $item; } ksort($placeHolder); return $placeHolder; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$args = array( 'orderby' => 'name', 'order' => 'ASC', 'child_of' => 0, 'parent' => 0, 'hide_empty' => 0, ); $categoriesT = get_categories( $args ); $categories = sortCategories($categoriesT); echo '<ul>' foreach($categories as $category) { echo '<li>' . $category->name.'</li>'; } echo '</ul>' |
Hits: 12