在我的 WordPress 中过滤tax_query

jak*_*513 1 wordpress

我想知道如何过滤属性区域,我尝试:

<?php     
                 $args = array(
                'post_type'         => 'estate_property',
                'post_status'       => 'publish',
                'tax_query'         => array(
                                                'taxonomy'  => 'property_area',
                                                'field'     => 'slug',
                                                'terms'     => 'pigalle',
                    ),
                );

            $selection = new WP_Query($args);
            ?>
Run Code Online (Sandbox Code Playgroud)

但都表现出来了!为什么 ?哈哈

谢谢

mai*_*o84 5

阅读分类参数

tax_query 参数是一个多维数组。您需要用另一个数组包装它:

<?php     
$args = array(
    'post_type'         => 'estate_property',
    'post_status'       => 'publish',
    'tax_query'         => array(
        array(
            'taxonomy'  => 'property_area',
            'field'     => 'slug',
            'terms'     => 'pigalle'
        )
    )
);

$selection = new WP_Query($args);
?>
Run Code Online (Sandbox Code Playgroud)