Note: The queries above return posts for a specific date period in history, i.e. “Posts from X year, X month, X day”. They are unable to fetch posts from a timespan relative to the present, so queries like “Posts from the last 30 days” or “Posts from the last year” are not possible with a basic query, and require use of the posts_where filter to be completed. The examples below use the posts_where filter, and should be modifyable for most time-relative queries.

Display ‘product'(s) where the custom field key is ‘price’ and the custom field value that is LESS THAN OR EQUAL TO 22.By using the ‘meta_value’ parameter the value 99 will be considered greater than 100 as the data are stored as ‘strings’, not ‘numbers’. For number comparison use ‘meta_value_num’.

Permission Parameters

Parameters relating to caching

In addition to the parameters mentioned above, you can also pass three different cache control flags: cache_results, update_post_term_cache, and update_post_meta_cache.

If you need to stop the data retrieved from being added to the cache you can pass cache_results as false (this is a master flag that will also turn off the other two), or you can be specific and pass update_post_term_cache and/or update_post_meta_cache depending on your requirements.

In general usage you should not need to use these – adding to the cache is the right thing to do – however they may be useful in specific circumstances.

An example of such circumstances might be when using a WP_Query to retrieve a list of post titles and URLs to be displayed, but in which no other information about the post will be used and the taxonomy and meta data won’t be needed. By not loading this information, you can save time from the extra unnecessary SQL queries.

Note: If a persistent object cache backend (such as memcached) is used, these flags are set to false by default since there is no need to update the cache every page load when a persistent cache exists.