admin管理员组文章数量:1404346
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.
<?php
$home_cats = get_post_meta($post->ID, 'home_cats', true);
$select_categories = explode( ',', $home_cats );
foreach ( $select_categories as $cat ) {
$tax_query = array(
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
本文标签: categoriesModifying category order
版权声明:本文标题:categories - Modifying category order 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744782737a2624810.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论