Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
villesiltala opened this issue Jan 24, 2020 · 0 comments
Open

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

villesiltala opened this issue Jan 24, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@villesiltala
Copy link

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',
];
@villesiltala villesiltala added the bug Something isn't working label Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant