A very common problem with WordPress sites is that you can’t easily reaarange category order. Sure, you can use a custom menu, but for some sites you have to reaarrange the order of your categories. This snippet will show you how to do it easily.
The code above will look for a specific category (Don’t forget to update line 5) and will replace it on top of all other categories. The code has to be pasted in your functions.php file.
<?php $categories = get_terms('books_category'); for( $i=0; $i<sizeof($categories); $i++ ){ if ( $categories[$i]->name == 'New Publications' ) : $latest = array($categories[$i]); unset($categories[$i]); endif; } if( isset($latest) ) array_splice( $categories, 0, 0, $latest ); ?>
Thanks to Sebastian for the great hack!