The WP_Query() custom field (i.e. meta) query can handle arrays for field values. You just need to add the compare key to your array:
$args = array(
'numberposts' => -1,
'post_type' => 'post',
'meta_query' => array (
array (
'key' => 'my_key',
'value' => 'target_value',
'compare' => 'IN'
)
) );
$new_query = new WP_Query( $args );
Related Posts:
- How to query ‘posts_per_page’ to display a different blog posts index template?
- Nested meta_query with multiple relation keys
- Some doubts about how the main query and the custom query works in this custom theme?
- WP_Query vs get_posts
- Display products from specific category in shop page
- Order posts by ID in the given order
- Query Multiple Post types each with own meta query
- Get the number of posts from the current page results
- WordPress Custom Query to show posts from last x years
- Query Custom Meta Value with Increment
- Perform query with meta_value date
- Meta Query with date and time on the same Day before given time
- How do I create my own nested meta_query using posts_where / posts_join?
- Exclude post on loop by multiple meta key value
- Query sticky posts with thumbnails
- 2 loops on page – one with orderby rand second orderby date
- Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first
- WP_Query on custom field and order results
- Query posts by specific word on title
- WP_Query last five posts, simply ordered by meta_value
- Five posts from a category in footer
- Multiple loops without repeating content
- Any number in meta key (wp query)
- WP_Query condition affects posts_per_page count
- Fetch Record based on meta key dates
- How to display multiple custom fields with the same meta_key in an ascending order?
- how to make members list directory through wordpress post custom meta key.
- Some doubts about how the main query and the custom query works in this custom theme?
- Array as ‘key’ in WP_Query
- How do I rewrite this loop as a new WP_Query style-loop?
- Include current post into loop
- Wp_query with 2 meta keys and array of meta values
- get_posts output always same post
- How to create custom query by keyword in post title?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Conditional operator OR not working with custom fields
- Get posts that do not have the same tags as current
- Should I reset $wp_query?
- Meta query compare for ID’s greater than specific ID
- 2 queries with counters
- Show single posts date, in a page of posts
- Why doesn’t my WP Meta Query return any results?
- Paginate pages with dynamic query
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Determine if ID is page or post and query the ID
- Custom template for password protected page
- WP_Query Class custom field parameters
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- WP_Query not returning correct result with meta_query parameter
- How do i create a custom post query when the meta value is an array?
- Duplice post with standard WP loop – fixed by using query_posts() instead
- ElasticPress is (aparently) messing with my search filters
- show most viewed post
- How do I stop the same post showing multiple times in a archive?
- Query for current post
- Custom query to retrieve oldest post and retrieve others with date interval
- Custom query for custom post type not getting correct post ID
- Problem with my loops
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- Meta Query if Values Don’t Exist
- Orderby query does not work for custom fields even with meta query
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- Custom WP_query and integrating into theme file
- query_posts() doesn’t seem to be called in my page
- Some doubts about how the main query and the custom query works in this custom theme?
- Ordering Posts by parent category, name ascending
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- query post based on comparison
- Converting an existing query_posts to WP_Query
- Multiple loop for “featured” items returns wrong posts
- WP Query – Show custom posts only if user contain some user meta
- Show number of posts AND number on current page (cannot make it work)
- how to show posts that are missing a meta_value
- WP_Query: query posts by ids from array?
- pre_get_posts with get_posts
- If two first numbers exist in wp_meta_query value
- Tax query clause inside a meta query clause?
- Change query_posts to WP_Query in page but does not work
- Can we return all category (not post) with Custom Query Filter? [closed]
- Search form not working with custom query?
- Only display post if published in last 24 hours?
- WP_Query loop else statement not executing
- Order post type by sum of two custom fields
- Ordering posts by custom field and grouped by month
- Function the_posts_pagination() not compatible with WP_Query arguments
- Woocommerce Get Orders By Meta Value
- WP_User_Query Orderby Not Working
- WordPress Query optimaization for slow query
- Meta query doesn’t remove placeholder escape before query
- modifying the loop multiple times with arguments passed through ajax to wp_query
- WP_Query – show posts where meta value and user_email match
- WP_Query causing links to not work
- WP_Query using meta_query with LIKE doesn’t return what it should
- How to organize a WP_Query’s list of posts by category and display category title?
- Including ‘cat’ => $cat breaks meta_query
- Pull Instagram images into an existing loop?
- First post outside of loop, homepage only?
- new WP_Query with order args – no more distinction between categories