Note: If you use the_post() with your query, you need to run wp_reset_postdata() afterwards to have Template Tags use the main query's current post again.
Note: Ticket #18408 For querying posts in the admin, consider using get_posts() as wp_reset_postdata() might not behave as expected.
*/ wp_reset_postdata(); } /* The 2nd Query (without global var) */ $query2 = new WP_Query( $args2 ); if ( $query2-. Eg, 'pillow -sofa' will return posts containing 'pillow' but not 'sofa' (available since Version 4.4). Remember that default clauses can be nested, in order to construct complex queries. Simple Custom Field Query: Display posts where the custom field key is 'color', regardless of the custom field value: Display 'product'(s) where the custom field key is 'price' and the custom field value that is LESS THAN OR EQUAL TO 22.
You shouldn't alter the properties directly, but instead use the methods to interact with them. See #Taxonomy Parameters for details on the syntax. This part of the query is parsed by parameter in the first (outer) array to describe the boolean relationship between the meta queries. By using the 'meta_value' parameter the value 99 will be considered greater than 100 as the data are stored as 'strings', not 'numbers'. Get attachments that are not images: To exclude certain mime types you first need to get all mime types using get_allowed_mime_types() and run a difference between arrays of what you want and the allowed mime types with array_diff().
Also see Interacting with WP_Query for some useful functions that avoid the need to mess around with class internals and global variables. For example, the first three represent 'is it a permalink? $unsupported_mimes = array( 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/tiff', 'image/x-icon' ); $all_mimes = get_allowed_mime_types(); $accepted_mimes = array_diff( $all_mimes, $unsupported_mimes ); $args = array( 'post_type' = 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.
determines what type of query it's dealing with (possibly a category archive, dated archive, feed, or search), and fetches the requested posts.
It retains a lot of information on the request, which can be pulled at a later date.
Most of the time you can find the information you want without actually dealing with the class internals and global variables.
There are a whole bunch of functions that you can call from anywhere that will enable you to get the information you need.
There are two main scenarios you might want to use properties are designed to hold this information: use the Conditional Tags to interact here.