从Wordpress查询中排除帖子ID

时间:2014-02-08 13:06:26

标签: php wordpress loops

我创建了一个wordpress查询,我试图排除一个id为1293的帖子。

这是我到目前为止所写的查询:

<?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(); ?>

1 个答案:

答案 0 :(得分:8)

post__not in需要一个数组。请尝试以下方法:

$my_query = new WP_Query(array (
    'post__not_in' => array(1293), 
    'post_type' => 'product',
    'posts_per_page' => '100'
));
相关问题