admin管理员组文章数量:1279145
I have the following simple query
$args = array('posts_per_page' => 7,
'tag_id' => 43,
'post_status' => 'publish',
);
$q = new WP_Query($args);
echo ($q->request); // produces the result below
Why is wordpress generating the "term_taxonomy_id IN (129)" , how can I get rid of that condition which seems to be filtering out all the posts? I checked and I definitely have 2 posts associated with tag_id=43 .
I just want to retrieve all published posts with tag_id=43 (max 7 ), should be simple.
SELECT SQL_CALC_FOUND_ROWS wpabr_posts.ID
FROM wpabr_posts
LEFT JOIN wpabr_term_relationships
ON (wpabr_posts.ID = wpabr_term_relationships.object_id)
LEFT JOIN wpabr_term_relationships AS tt1
ON (wpabr_posts.ID = tt1.object_id)
WHERE 1=1
AND ( wpabr_term_relationships.term_taxonomy_id IN (129)
AND tt1.term_taxonomy_id IN (43) )
AND wpabr_posts.post_type = 'post'
AND ((wpabr_posts.post_status = 'publish'))
GROUP BY wpabr_posts.ID
ORDER BY wpabr_posts.post_date DESC
LIMIT 0, 7
I have the following simple query
$args = array('posts_per_page' => 7,
'tag_id' => 43,
'post_status' => 'publish',
);
$q = new WP_Query($args);
echo ($q->request); // produces the result below
Why is wordpress generating the "term_taxonomy_id IN (129)" , how can I get rid of that condition which seems to be filtering out all the posts? I checked and I definitely have 2 posts associated with tag_id=43 .
I just want to retrieve all published posts with tag_id=43 (max 7 ), should be simple.
SELECT SQL_CALC_FOUND_ROWS wpabr_posts.ID
FROM wpabr_posts
LEFT JOIN wpabr_term_relationships
ON (wpabr_posts.ID = wpabr_term_relationships.object_id)
LEFT JOIN wpabr_term_relationships AS tt1
ON (wpabr_posts.ID = tt1.object_id)
WHERE 1=1
AND ( wpabr_term_relationships.term_taxonomy_id IN (129)
AND tt1.term_taxonomy_id IN (43) )
AND wpabr_posts.post_type = 'post'
AND ((wpabr_posts.post_status = 'publish'))
GROUP BY wpabr_posts.ID
ORDER BY wpabr_posts.post_date DESC
LIMIT 0, 7
Share
Improve this question
edited Nov 5, 2021 at 10:58
Rup
4,4004 gold badges29 silver badges29 bronze badges
asked Nov 4, 2021 at 12:09
shelbypereirashelbypereira
1375 bronze badges
1 Answer
Reset to default 1After extensive searching, I found that this was related to the PolyLang plugin I had installed. When it adds language support it modifies the WP_Query and lang='' MUST be added as a filter to specify all languages or lang='fr' to specify searching only in French for example, else by default it uses the default language of the wordpress installation.
本文标签: Get All posts by TagId not workingquery seems to contain extra termtaxonomyid
版权声明:本文标题:Get All posts by Tag_Id not working, query seems to contain extra term_taxonomy_id 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741234090a2362658.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论