我正在尝试使用WP\\u查询访问自定义帖子类型和分类的帖子元,然后使用特定的帖子元查询帖子
到目前为止,我已经绑定了以下代码:
$hot_args = array(
\'post_type\' => \'video\',
\'posts_per_page\' => \'6\',
"order" => "DESC",
\'meta_key\' => \'post_views_count\',
\'orderby\' => \'meta_value_num\',
\'date_query\' => array(
array(
\'after\' => \'1 week ago\'
)
),
"post__not_in" => $posts__not_in,
\'tax_query\' => array(
array(
\'taxonomy\' => \'video_cat\',
\'field\' => \'slug\',
\'terms\' => "all"
)
),
);
$hot_query = new WP_Query( $hot_args );
此代码不起作用,不返回任何结果
对于普通帖子,这段代码可以正常工作,但对于自定义帖子类型,这段代码无法正常工作,如何才能使其适用于自定义帖子类型?
SO网友:MMTDesigner
找到问题;)
答案是
$hot_args = array(
\'post_type\' => \'video\',
\'posts_per_page\' => \'6\',
"order" => "DESC",
\'meta_key\' => \'post_views_count\',
\'orderby\' => \'meta_value_num\',
\'date_query\' => array(
array(
\'after\' => \'1 week ago\'
)
),
"post__not_in" => $posts__not_in,
);
$hot_query = new WP_Query( $hot_args );
上周没有视频,因为我的自定义帖子类型已存在,因此没有可返回的内容:)