February 15, 2017
Template layouts (and client requests) will often require a list of categories to be laid out in a specific order to draw attention to different content.
Add a numbered “order” field to your categories using Advanced Custom Fields and sort through the categories using the following:
$categories = get_categories( $args );
usort($categories, function($a, $b) {
return get_field("category_order", "category_".$a->term_id) - get_field("category_order", "category_".$b->term_id);
});
foreach ($categories as $category){
Sourced here.