How to rearrange WordPress categories order
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 WP Snippets for the great hack!

Comments are closed.