Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.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
Php 正在查询到自定义分类法帖子的最近帖子_Php_Wordpress - Fatal编程技术网

Php 正在查询到自定义分类法帖子的最近帖子

Php 正在查询到自定义分类法帖子的最近帖子,php,wordpress,Php,Wordpress,我试图将文章从自定义分类法显示到索引页,但当我查询结果时,也找到了最近添加的与分类法无关的文章 $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 4, 'tax_query' => array(

我试图将文章从自定义分类法显示到索引页,但当我查询结果时,也找到了最近添加的与分类法无关的文章

$args = array(
             'post_type'         => 'post',
             'post_status'       => 'publish',
             'posts_per_page'    =>  4,
             'tax_query'         =>  array(
                                       'taxonomy' => 'city',
                                       'field' => 'id',
                                       'terms__in' => 227,
                                                )
);
$arr_posts = new WP_Query($args);
我还可以选择在屏幕上显示最近的帖子,所以我想知道这是否是问题的原因


如果是这样的话,我想知道将最近的文章从自定义分类法显示到首页的正确方法

您的
税务查询不正确。请检查以下查询

$args = array (
    'post_type' => 'post',
    'post_status' => 'publish',
    'posts_per_page' =>  4,
    'tax_query' => array(
        array(
            'taxonomy'  => 'city',
            'field'     => 'term_id',
            'terms'     => array( 227 ),
        )
    ),
);
$arr_posts = new WP_Query($args);