For custom field queries you can’t use an array for multiple keys, unfortunately. What you want is something like this:
$args = array(
'post_type' => array('gym_location', 'gym_term'),
'orderby' => 'title',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'term_active',
'value' => '1',
'compare' => '=='
),
array(
'key' => 'location_active',
'value' => '1',
'compare' => '=='
),
'relation' => 'OR',
)
);
See https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
Related Posts:
- Mixing regular and custom post types (with meta_query) on home page
- WP_Query() show posts that end later than today
- WP_Query orderby custom field then post_date in one query
- Filtering a WP_Query meta_query by numeric values isn’t working
- Using Query Posts With Multiple Post Types And A Taxonomy
- Can’t sort order of wp_query with 2 meta keys
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- Combine tax_query and meta_query in WP_Query
- query order by date on custom type: wrong order
- exclude custom post type by meta key in wp_query
- Filter posts with meta_query NOT IN where value has multiple values
- Filtering by Post Meta Custom Fields – Performance
- Is it possible to apply a meta_query to one specific post type in a query with multilple post types?
- Setting proper query for multiple custom admin filters
- WP_Query: include custom post type only with specific meta value
- Returning a list of custom post types excluding those without a specific meta_value
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- wp_query check if integer exists in custom field’s array
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How to do WP_Query with two meta fields with orderby clause
- Stuck in Order by more then one
- Why is this query not working? (Standard posts + custom post type)
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Possible to filter custom post type with multiple meta data?
- Query based on custom fields start and end date
- WP_query – Filter by tax_query and meta_query using multiple select
- Getting a custom post’s custom field based on another custom post’s custom field select
- find custom post type post by searching its custom field with my string
- WP_Query of custom post type sorted by meta_key has unexpected results
- Create a WP_Query where if the first value of the first row is equal to the second compare other value
- Query Posts, order by meta value
- WP_Meta_Query object with conditionals
- Sorting by meta_key different to search criteria?
- Using WP meta query to show custom post types by a start and finish date
- Two queries – one with checkbox ticked, one without – comparing meta_query
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- build child and anchestor three from post parent
- meta query condition don’t work
- Custom query result empty on page 2
- Use WP_query to match post types based on custom field values
- meta query multiple values for the same key
- Sort custom post archives by a meta value from a different custom post type?
- Custom post types – meta_query: search lesson which starts sooner
- post type => ‘any’ not applied my custom queries
- How to get the posts that my following users are liked?
- Meta_Query refuses to return results
- Not able to get my custom search result using meta_query and tax_query together?
- Query events post type after current date and timezone
- Conditional posts in WP_query for search
- Selecting posts older than the current Unix epoch timestamp
- Custom Query With Multiple Meta Key Value
- Trying to combine multiple WordPress queries
- Querying meta values within an array
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Order Wp Query by earliest of 3 dates meta query
- WP_Query() displaying past post / event
- WP Query Conditionally query meta and taxonomy
- How to use a custom post type archive as front page?
- Combining queries with different arguments per post type
- How to make a WP_Query search with custom post types?
- The Operator “NOT IN” Does Not Work In tax_query
- Ordering posts having multiple post-meta date fields
- How to get the parent’s taxonomy?
- Help with hierarchical custom taxonomies and permalinks…almost there
- New WP_query in template not working with CPT+category on some pages
- Displaying a specific post in a wp query by post id
- Display custom post type taxonomy and month
- Optimised Code for Pulling Taxonomy Posts
- How can I get the first 50% of all posts (within a custom post type)?
- is there a way to retrieve posts that do not have a featured image assigned?
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- shortcode to show custom post types by category
- Genesis filterable portfolio isotope [closed]
- convert custom query to wp_query
- Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”
- filter custom post type by meta key in dashboard
- How to use load more custom post type data normal or according to on click category tab In WP
- Meta Query Not Returning Output Despite Having Matching Values
- filter search custom field query
- Using wp_query to modify the loop in index.php for a CPT
- Wp Query with multiple custom tag(taxonomy) by get the terms
- Post ordering not working with custom field
- Query custom posts from custom taxonomy
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Random item on Custom Query working Local but not on live
- Using OR relation in meta_query to check for a value before sorting by another
- Filtering posts based on three taxonomies
- meta_query Where the key value is stored as an array
- How can I get custom post types to recognize pretty permalink variables?
- Query the title of the page to show posts with matching category in the loop
- WP Query tax_query not returning posts
- wp_query return nothing
- date_query won’t accept day parameter, but will accept month and year for a custom post
- Custom Post ‘Post Per Page’ Crashing Page?
- Issue with permalinks for custom post type
- Paged within a custom content type template [duplicate]
- loop through custom post-type with two meta_keys
- How to exclude certain portfolios from a loop
- show the most recent date of all posts to display on front end