Php 按ACF选项排序,也可按当前类别排序-自定义帖子类型

Php 按ACF选项排序,也可按当前类别排序-自定义帖子类型,php,wordpress,loops,advanced-custom-fields,Php,Wordpress,Loops,Advanced Custom Fields,使用高级自定义字段插件,我创建了一个选择下拉列表,其中包含6种成员类型。我所有使用此自定义字段的“列表”都被指定为6个字段之一 我已经设法让我的列表以成员级别的顺序显示,但是它并没有定义您当前所在的类别。它还从其他所有类别中获取列表 <?php // args $args = array( 'numberposts' => -1, 'post_type' => 'directory_listings', 'meta_key' => 'm

使用高级自定义字段插件,我创建了一个选择下拉列表,其中包含6种成员类型。我所有使用此自定义字段的“列表”都被指定为6个字段之一

我已经设法让我的列表以成员级别的顺序显示,但是它并没有定义您当前所在的类别。它还从其他所有类别中获取列表

<?php 
// args
 $args = array(
     'numberposts' => -1,
     'post_type' => 'directory_listings',
     'meta_key' => 'membership_type',
     'orderby' => 'meta_value',
     'taxonomy' => 'listing_category'
 );

// query
$wp_query = new WP_Query( $args )

?>

<?php if (have_posts()) : ?>

    <?php
    while( $wp_query->have_posts() ) {
        the_post();
        ldl_get_template_part('listing', 'compact');
        ldl_get_featured_posts();
    }
    ?>

<?php else : ?>

<?php endif; ?>


另外,我正在使用插件:

WP\u查询没有
分类法
参数,您应该使用
税务查询
。更多信息请访问

要动态获取当前分类术语(假设您位于
listing\u category
taxonomy页面上):


啊,好的,我现在看到了。作为测试,我将“术语”设置为我的一个类别中的“关联”。工作得很好,但是我怎样才能像这样动态地抓取当前类别的slug。
'tax_query' => array(
    array(
        'taxonomy' => 'listing_category',
        'field'    => 'slug',
        'terms'    => 'my-listing-category',
    ),
),
'tax_query' => array(
    array(
        'taxonomy' => 'listing_category',
        'field'    => 'term_id',
        'terms'    => get_queried_object_id(),
    ),
),