No, it doesn’t work like that because meta_query
is for custom fields and tax_query
is for taxonomies.
But what you could do is run two separate queries to get all of the IDs that qualify, and then use those IDs in a 3rd query with post__in
. For example:
$cat_query_args = array(
'posts_per_page' => -1,
'cat' => '63',
);
$meta_query_args = array(
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'placing',
'value' => 'nn',
)
)
);
$cat_query = get_posts( $cat_query_args );
$meta_query = get_posts( $meta_query_args );
$merged_posts = array_merge( $cat_query, $meta_query );
$combined_query_args = array(
'posts_per_page' => 6,
'offset' => 0,
'post__in' => $merged_posts
);
$combined_posts = get_posts( $combined_query_args );
Related Posts:
- Query all posts where meta value is empty
- Meta Query with date and time on the same Day before given time
- meta_query: check if number exists
- Check if searched number is within the post meta value
- How to add date_query to meta_query array
- get_posts query is taking about 40 seconds to execute
- Slow query when selecting with large meta query or post__in
- WordPress extremely slow when using get_posts with multiple meta_query relations
- How to query posts based on lat-lng coordinate as post meta?
- Set Alias for meta_query arguments in get_posts()
- Using get_posts vs. WP_Query
- Delete all posts from WordPress except latest X posts
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Custom WP_Query order by post_meta and (author) user_meta
- get_posts with multiple categories
- Using custom meta_query with relation not working as expected
- Perform query with meta_value date
- WP_Query meta_query where meta value ends in space
- Nested query inside Logical operator OR not working in meta_query
- What is an efficient way to query based on post_meta?
- How do I create my own nested meta_query using posts_where / posts_join?
- Use post__in and post__not_in together?
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Compare two meta-fields in a wp_query (where meta-field-A is larger than meta-field-B)
- Different Results with query(‘s=computer’) vs get_posts(‘s=computer’)?
- Exclude post on loop by multiple meta key value
- Get all posts without tags
- How to find out what “Blog pages show at most” is set to [duplicate]
- Order posts by meta value and Date
- Query sticky posts with thumbnails
- how to speed up a complex wp_query?
- Meta query with order by another custom field
- Creating arguments from loop for WP_Query meta_query
- Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first
- Single meta_query query using OR instead of AND in request’s WHERE statement
- How to do meta_query for attachments?
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Why isn’t my `meta_query` array functioning properly?
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- Suggestions on making this query/code more performant
- Order by meta value (numeric value lower to higher)
- Large AND OR query timing out
- WP_Query with different postmeta filter for each categories
- Slow WP_Query with ‘OR’ on meta_query
- get_post_meta slowing down my page load (in a plugin)
- How to filter a query by multiple meta keys and order by other meta keys
- Get all posts which was posted on X Days WordPress
- Meta Query doesn’t works as espected
- Advanced WP_Query with meta_query, orderby?
- get_posts always returning the same number of posts = 5
- Issues with search after added meta_query
- Display posts with specific value first in query
- get_posts custom field
- How to apply a function to a metadata value before launch a WP Query?
- WP_Query: apply an SQL function to meta fileld value
- How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?
- How to create dynamic value in WP_Query meta_query
- Woocommerce: order posts by meta key
- query post by author gender
- How to access $wp_query object from array of posts given by get_posts?
- How do I add an item to the WP admin menu?
- Multiple meta query from array
- get_posts query matches too many results
- WP_Query with 4 post meta field arguments gives 500 internal server error
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Custom meta_query order for Elementor based on post meta key [closed]
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- ElasticPress is (aparently) messing with my search filters
- Meta query ignores multiple values of the key
- Multiple meta_query not returning rows
- meta_query order by date present -> future then show null
- Related posts queries
- Check for not NULL not working in meta query
- Get unique post by meta value using wp_query
- Query against multiple locations within single custom post type post
- WP_Query, ACF field and array
- Order by Date Custom Field
- WP Query. Ordering posts by another post types meta
- Complex Meta Query
- Get posts meta_query by repater field
- Query 3 meta_key and orderby
- wp_query sorting – one specific meta_key value at last and then sort by create date
- meta_query not working with the_content()
- Filter posts/pages by user_role array
- WP_Query with MetaQuery issue
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- WP_Query with meta_value_num and meta_query not paged correctly
- Post Query not working after updating to 4.1
- Orderby Meta Value and Query from Meta Query
- The sorting of posts by a meta_query with two keys fails while separated as single queries it works
- Sort posts in dashboard using custom field; also include posts where field isn’t set
- 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
- How to replecate the _fields parameter in custom REST api endpoint
- How to retrieve _embed (etc) fields in get_posts custom query?
- Using ‘meta_query’ with the ‘pre_get_posts()’ hook disables searching for post titles
- Get posts using multiple values from ACF checkbox as meta query wordpress
- WP Query returning all posts when Meta_query is null