This shortcode is used to get list of posts based various criteria. aw2_query_posts behind the scene uses either get_posts function or WP_Query class depending on the query_type parameter. It returns a collection, which can be accessed using aw2_collection and aw2_loop. We pass arguments to aw2_query_posts using JSON value, for which attributes are exactly same as that of WP_Query.
This is used to uniquely identify query result, which can be later accessing this ID. It defaults to ‘default_collection’
if only one value is required from the collection then you can directly put the parameters of aw2_collection to get that value.
main | tax_query | meta_queryIt allows us to break complex queries into parts. It gives us ability to add or remove parts of a query based on conditions. When part is main it destroys all existing parts and creates a new query, so it is important that when you are breaking a query into parts, part=main is first. Part tax_query indicates that JSON value is for running taxonomy query, similarly part meta_query indicates that JSON value is to be used for creating meta query.If parts is not used, then query executes immediately.
AND | ORIt defaults to ‘AND’. It is used in taxonomy and meta query to define the relationship. See Taxonomy Query for details
It is comma separated string of taxonomy slugs which can be used to build a series of taxonomy conditions based on request parameters. It is equivalent to writing ‘AND’ relation based tax_query for each taxonomy. It looks into Request object to find “taxonomy=terms” pairs. It comes in handy when we are doing filtering of data based on taxonomies.
It is similar to request_taxonomy, with only difference being it uses param object instead of request object.
get_posts | get_pages | wp_queryIt defaults to ‘get_posts’. You should use wp_query, if you need use pagination with your query.
It defaults to ‘false’. If set to true, it will run a query which is in parts. It is required for execution of query if they have been split into parts. You don’t need to set run, if parts is not used.
p.s remove the space between “[” and “aw2” in the examples below, they have been added to avoid their execution on this page.
This is most common usage of aw2_query_posts, it will put the results directly into ID default_collection
Using parts to split complex queries using ID, if ID is not specified it will assume default_collection.
Using request_taxonomy along with aw2_query_posts