Skip to content

Query for a missing meta key results in too many found posts #45

@villesiltala

Description

@villesiltala

If a WP query has a meta query with a key that is not found in any of the posts, found posts value is incorrect. For example, if a post type is set for the query and a meta key is not found in any of posts for the post type, found posts equals to the number of posts in the post type. This might be Polylang related, since this happened on a site with Polylang activated. The number of found posts was equal to the number of all posts in all of the installed languages.

Steps to reproduce:

  1. Install and activate Polylang Pro
  2. Create a post type and publish posts for multiple languages
  3. Do a WP query with a meta query for a missing post meta key

Example of the used WP query args:

$args = [
    'post_type'      => 'my_custom_post',
    'posts_per_page' => 10,
    'paged'          => 1,
    'order'          => 'ASC',
    'orderby'        => 'meta_value',
    'meta_key'       => 'my_missing_meta_key',
];

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions