Your code should work in theory. Your failure is not caused by the code in your question but rather due to external factors. Something else is causing this failure
DEBUGGING THIS ISSUE
-
Turn on debug and check for obvious errors and warnings. This should be a good indication on the soundness of all your code on a particular page
-
Clear all caches, not just browser cache, but any cache plugin
-
Disable all your plugins and switch to a bundled theme. Check if the error persist. Re-enable your plugins one by one and test after each one. This should give you an indication if a plugin is causing your issue. Lastly, re-enable your theme. By now you should have a clear indication where your problem is coming from.
-
Regarding the amount of posts and the difference, check for stickies.
Related Posts:
- Getting attachments by meta value
- How to make Meta Query case sensitive?
- Fetch Record based on meta key dates
- how to make members list directory through wordpress post custom meta key.
- Large AND OR query timing out
- How do i create a custom post query when the meta value is an array?
- Trouble with serialized metadata
- Query against multiple locations within single custom post type post
- Can wp_query return posts meta in a single request?
- Use REGEXP in WP_Query meta_query key
- Meta query with string starting like pattern
- compare meta_query in get_posts arguments
- meta_query where value is equal to given value
- querying with custom meta field with meta_query
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- What is an efficient way to query based on post_meta?
- WP_Query not working as expected for attachments and custom meta_query
- How can I create a WP_Query that returns posts where one meta_value
- WP Meta Query for some meta (array) values
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- How to get sum of meta_values of a meta_key in wp_query according to conditions
- Order by meta_key in custom post type doesn’t affect the query
- meta_key and meta_value not working together
- Order posts by meta value and Date
- Order Posts by meta value AND published date
- Get meta info related to current post
- Group WP_Query by meta_key date
- exclude posts with a specific custom field and value
- Performance when getting post meta for post retrieved by meta value
- Get attachment by meta_key value
- Display custom field meta outside loop, site wide
- Meta_query with multiple keys and multiple values
- meta_query BETWEEN, but the range is stored in the custom field
- Extend product search with meta in WooCommerce
- meta_value_num not ordering all items
- meta_compare not comparing whole integer
- Is it possible to retrieve all posts with a certain value for metadata?
- Filter posts by comparing custom meta value against postdate
- Display posts with specific value first in query
- Get every post with value in meta key
- Order WP_Query results by meta key value in custom query
- Nested array issue in meta_query
- Display post meta conditionally based on it’s value
- add_query_arg to compare and display events from a certain date
- Comparing 2 Decimal Numbers from custom fields and displaying posts
- Query posts by searching for a string in a meta field
- WP_Query meta compare must include ALL array values
- meta_query weird behaviour, static int will work, but not user data
- Query multiple post types, but different order for each
- Order by the first array within a meta_query
- Query ACF relationship field – Comparator IN – Value array
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- wp query to use both author id and meta_query
- WP Query – grouping posts by same meta key, adding together values from another key
- Meta query ignores multiple values of the key
- meta_query is overriding default search
- show most viewed post
- Comparing Meta Field date in WPQuery using Meta_Query?
- Why can my filter query SOME metadata but not other metadata?
- Getting posts by custom field value
- WP_Query, ACF field and array
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- Order by Date Custom Field
- Query by meta value (add a dropdown of all values)
- Order Posts By Custom Field That is an array of objects
- Saving custom fields for WP_Query to retrieve
- Meta key in wp_query bug?
- Custom WP_query and integrating into theme file
- How to show all the associated posts with specific date of data metabox?
- WP Meta Query at depth 2
- Using custom field as ‘orderby’ value causing post grouping by publish date
- WP_Query Posts by Metadata from Option Tree
- Compare meta key separation
- Sorting Posts with meta value not working
- Return a single custom post from multiple meta queries
- Custom Search Query – include only custom fields and title
- query post based on comparison
- Querying meta values within an array
- Get posts by meta value except one post [closed]
- WP_Query by meta key not returning any posts
- Extend search query to search meta keys values based on search string
- order by numeric value for meta value
- How to query posts based on lat-lng coordinate as post meta?
- WP_Query displaying ALL posts
- How do I create my own nested meta_query using posts_where / posts_join?
- Meta Query for specific months
- Filtering by Post Meta Custom Fields – Performance
- ACF Date Based wp_query
- Mysql query and order meta value
- Get a list of posts with associated meta_value
- Order ascending is ignored in meta query?
- Search posts missing a particular custom field
- Sort by presence of thumbnail
- What’s missing in this wp_query and meta_query
- How to use the Term Object from a custom select field in a query
- I can’t get post based on its postmeta value and key
- The sorting of posts by a meta_query with two keys fails while separated as single queries it works
- Sort Posts with custom meta key by default which is currently set as optional
- WP_Query with several meta_query-statements and order by meta_value