Modifying category order

I am working with a directory style wordpress theme that displays categories in masonry style columns with their posts listed under each category title. The categories are appearing on the front page in alphabetical order and I would like to change this preferably using advanced custom fields. I have managed to control the post order using acf just fine but am stumped as to how to change category order.

$home_cats = get_post_meta($post->ID, ‘home_cats’, true);
$select_categories = explode( ‘,’, $home_cats );
foreach ( $select_categories as $cat ) {
$tax_query = array(
‘taxonomy’ => ‘category’,
‘field’ => ‘id’,
‘terms’ => $cat,
$term = get_term( $cat, ‘category’ );
$term_name = $term->name;
$args = array(
‘posts_per_page’ => -1,
‘post_type’ => ‘post’,
‘tax_query’ => $tax_query,
‘meta_key’ => ‘placement’,
‘orderby’ => ‘meta_value_num’,
‘order’ => ‘ASC’,
$the_query = new WP_Query( $args );
if( $the_query->have_posts() ) :

I assumed adding orderby and order fields to first tax_query array was the way to achieve this but it doesn’t change a thing. Is it glaringly obvious to one of you experts where I am going wrong here? Thanks

Read more here:: Modifying category order

Leave a Reply

Your email address will not be published. Required fields are marked *