Support » Fixing WordPress » post__not_in query

  • Resolved greencode

    (@greencode)


    I’m using the following to display a list of posts from category with ID 27 but I would also like to exclude a post with ID of 297. Not too sure what I’m doing wrong.

    <?php /* Start the Loop */ ?>
    <?php
    $featuredPosts = new WP_Query();
    $featuredPosts->query('cat=27&post__not_in=297');
    while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>
    <li><a href="<?php the_permalink() ?>"><?php the_title() ?></a></li>
    <?php endwhile; ?>

    Any help would be much appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘post__not_in query’ is closed to new replies.