【问题标题】:Wordpress posts__not_in not functioningWordpress 帖子__not_in 不起作用
【发布时间】:2017-10-26 15:50:59
【问题描述】:
      $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 类吗?

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    你的参数错了改一下

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

    【讨论】:

    • 我多么愚蠢。谢谢
    猜你喜欢
    • 1970-01-01
    • 2013-12-23
    • 2018-04-25
    • 2013-11-10
    • 2015-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-22
    相关资源
    最近更新 更多