最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - WP_Query adds "(wp_posts.ID = '0')" so no results are returned

programmeradmin1浏览0评论

I am doing a very simple WP_Query:

  $query = new WP_Query([
    'pagename'  => 'some-post-slug',
    'suppress_filters' => true // used by WPML to search in ANY language
  ]);

However, the query that is performed is:

 SELECT wp_posts.* 
 FROM   wp_posts 
 WHERE  1 = 1 
        AND ( wp_posts.id = '0' )  // notice this line
         AND wp_posts.id = 171073 
         AND wp_posts.post_type = 'post' 
 ORDER  BY wp_posts.post_date DESC 

Why is ( wp_posts.id = '0' ) returned? If I remove it from the query, then the page is found without any issues.

Sidenote: Also strange that it searches by wp_posts.id = 171073 when I defined a post_name.

发布评论

评论列表(0)

  1. 暂无评论