Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 为什么税务查询返回0=1_Wordpress - Fatal编程技术网

Wordpress 为什么税务查询返回0=1

Wordpress 为什么税务查询返回0=1,wordpress,Wordpress,我使用这段代码获取定制分类法(slug:st_ai_cat)类别(slug:quizes)下的所有帖子 //查询 $term_name=get_query_var('taxonomy');//当前分类法 $cat_name=get_query_var('term');//当前猫名 $my_query=新的WP_查询(数组('post_type'=>'st_ai', “发布状态”=>“发布”, “tax_query”=>数组( 排列( “分类法”=>$term\u名称, '字段'=>'段塞', “

我使用这段代码获取定制分类法(slug:st_ai_cat)类别(slug:quizes)下的所有帖子

//查询
$term_name=get_query_var('taxonomy');//当前分类法
$cat_name=get_query_var('term');//当前猫名
$my_query=新的WP_查询(数组('post_type'=>'st_ai',
“发布状态”=>“发布”,
“tax_query”=>数组(
排列(
“分类法”=>$term\u名称,
'字段'=>'段塞',
“term'=>数组($cat_name),
“包含子项”=>false,
)
)
));
echo var_dump($my_query);
如果($my\u query->have\u posts()){
呼应“好”;
}
?>
但是tax_查询返回0=1,这意味着false。我检查了数据库,结果是正确的。为什么还有问题?谢谢。

您所说的“税务查询返回0=1”是什么意思?
// the query
$term_name = get_query_var('taxonomy'); // current taxonomy
$cat_name = get_query_var( 'term' ); // current cat name

$my_query = new WP_Query(array('post_type'=>'st_ai',
                               'post_status' => 'publish',
                               'tax_query' => array(
                                   array(
                                      'taxonomy' => $term_name,
                                      'field' => 'slug',
                                      'term' => array($cat_name),
                                      'include_children' => false,
                                   )
                               )
                               ));
echo var_dump($my_query);

    
if ( $my_query->have_posts() ) {
    echo "good";
}
?>
<ul>