以下代码应该获取自定义分类中没有特定术语的帖子。目前它仍然吸引着他们。是不是少了点什么。
$args = array(
'numberposts' => '3',
'post__not_in' => $post_not_in,
'tax_query' => array(
'taxonomy' => 'topic',
'terms' => 9,
'field' => 'id',
'operator' => 'NOT IN'
)
);
$extras = get_posts($args);
最佳答案
Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
—Wordpress Codex on Taxonomy Parameters
你尝试过吗?
$args = array(
'numberposts' => '3',
'post__not_in' => $post_not_in,
'tax_query' => array(
array(
'taxonomy' => 'topic',
'terms' => 9,
'field' => 'id',
'operator' => 'NOT IN'
)
)
);
$extras = get_posts($args);
关于WordPress 获取不在自定义分类术语中的帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21433200/