我有一个名为$ excludes的变量,它具有以下内容:12,32,345,676,677,733,980我可以像这样使用post__not_in:
$the_query = new WP_Query( array( 'posts_per_page' => 10, 'post__not_in' => $excludes ) );
排除在$ excludes中找到的帖子ID。
答案 0 :(得分:1)
您需要在array()
post__not_in
<{1}}中传递'post__not_in' => array(343, 493, 166),
尝试: -
$str = '12,32,345,676,677,733,980';
$arr = explode(',', $str);
$the_query = new WP_Query( array( 'posts_per_page' => 10, 'post__not_in' => $arr) );