2014-02-08 100 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

是的,它絕對正確,我會編輯頂部向您展示我正在使用的完整代碼 –