Wordpress帖子____无效

时间:2017-10-26 15:51:00

标签: php wordpress

      $posts_not_included = array( get_the_ID() );

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

      query_posts($args);

我在单个帖子页面中有这个代码。该页面展示了一个帖子,然后我尝试调用query_posts来获取其他帖子。然而,尽管ID由get_the_ID()显示,但是显示了当前打开的帖子。是正确的。难道我做错了什么?我是否需要使用WP_Query类?

1 个答案:

答案 0 :(得分:3)

您的参数错误更改

$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);