Sefam
Sefam

Reputation: 1773

Wordpress posts__not_in not functioning

      $posts_not_included = array( get_the_ID() );

      $args = array(
          'posts_per_page' => 3,
          'posts__not_in' => $posts_not_included
      );

      query_posts($args);

I have this code in a single-post page. The page showcases a post, and then I try to call query_posts to get the other posts. However, the post I'm currently on is shown, despite the ID being shown by get_the_ID(); is correct. Am I doing something wrong? Do I need to use the WP_Query class instead?

Upvotes: 2

Views: 133

Answers (1)

Shahbaz A.
Shahbaz A.

Reputation: 4356

Your parameter is wrong change it

$posts_not_included = array( get_the_ID() );

  $args = array(
      'posts_per_page' => 3,
      'post__not_in' => $posts_not_included // right argument is post not posts
  );

  query_posts($args);

Upvotes: 3

Related Questions