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
Add a comment  | 

1 Answer 1

Reset to default 1

After 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