2014-02-08 101 views
1

我创建了一个WordPress的查询和我试图排除一个职位与1293排除帖子ID

这里的ID是迄今为止我已经写查询:

<?php 
$my_query = new WP_Query(array (
'post__not_in' => array(1293), 
'post_type' => 'product', 
'posts_per_page' => '100' 
)); 
?> 
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?> 

<?php the_title(); ?> 
<?php the_content(); ?> 

<?php endwhile; ?> 
<?php wp_reset_query(); ?> 

回答

6

post__not in需要一个数组。请尝试以下操作:

$my_query = new WP_Query(array (
    'post__not_in' => array(1293), 
    'post_type' => 'product', 
    'posts_per_page' => '100' 
)); 
+0

不,这仍然不起作用,产品仍然显示 –

+0

您确定该ID是正确的吗? – markusthoemmes

+0

是的,它绝对正确,我会编辑顶部向您展示我正在使用的完整代码 –