You are missing relation
argument for inner meta_query
arrays as described in the Code Reference.
Also, when you use 'compare'=> 'IN'
, the 'ship-from'
value should be the array.
$args = array(
'post_type' => 'post',
'meta_query' => array(
'relation' => 'AND', // note this!
array(
'key' => 'ship-from',
'value' => 'usa',
'compare'=> 'IN'
),
array(
'key' => 'profit-margin',
'value' => array(0,100),
'meta_type' => 'numeric'
'compare' => 'BETWEEN'
)
)
);
Related Posts:
- Modern Tribe Calendar wp-query with meta query not working at all
- How to display custom field on homepage
- Can an array be used as a meta_query value?
- WP Query with custom Shortcode
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- Custom query, checking values of multiple meta keys
- Is it possible to retrieve all posts with a certain value for metadata?
- WP_Query: getting posts where custom field exists
- How to hide posts of a specific custom category in WordPress?
- Passing an array into WP_Query as a variable
- WordPress meta_query >= &
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
- wp_Query with mutuplea values returns all posts
- meta_query search names when they have middle initials
- Usermeta data unserialize, extract and display in table in WordPress
- Efficient way of querying for a “fallback” post?
- How to update single value in multi dimensional Post Meta?
- WP_Query | Help me create a search term with an ‘OR’ relation?
- Why does “get_option” pull in the older value in options.php, rather than the newer value, on submission of a form?
- WP_Query use for a filter with multiple Taxonomies and Terms
- Duplicates with WP_Query loop
- Display related products with custom output
- How do I dynamically generate args for wp_query?
- Use wp_get_recent_posts with search term
- have_posts() execution failure
- Can’t search posts using WP_QUERY inside AJAX Function
- How can I use wp_query to show all product data using just the products ID?
- Get Current User Id Inside a Loop Returns 0 For a Shortcode
- Custom page archive query by url var calling page twice on one of my custom queries?
- How to query for posts with a null or blank post_name?
- WordPress pagination not working with search page
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- Add more button if more 8 items
- How to store post ID’s in cookie or session to display the same posts later
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- auto-populating custom nav with all items from custom post type
- Configuring a meta query with multiple post types that have the same relationship on a single page
- WordPress theme options error
- Get posts from multiple post type
- get_users meta_query: REGEXP not working for matching new lines
- WP_Query fails despite having 1 post
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- wp_query get the 2nd post
- How to add div blocks after certain set of post
- the_posts_pagination() not working in wpquery
- Convert a string into a decimal number for use in query
- Increment paged on WP_Query
- Hide posts if user is added to it WP_query
- User Meta Value not echoing despite Var_Dump Showing correct string
- Custom route and query
- Getting posts to exclude from array
- How to insert wp_users ->user login name to wp_terms when a new user registering?
- Custom post type permalinks do not appear using the link functions
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- Modify main query before it run without pre_get_post
- Sort posts in a specific way
- array_rand not working correctly?
- WP_Query() load selected post
- How to extract information from a wp_query result?
- posts_nav_link pulling in multiple post types
- Modifying WP URL handing code?
- orderby meta_value_num is not working, giving default order
- How can I modify this code to make the search box include tags and meta
- Free search and custom taxonomy query not providing the same result
- How do I reset $wp_query in a function?
- How to sort WooCommerce products page by latest in-stock items first?
- WP_Query for woocommerce products with a pattern as a post_title
- How do I make these combination select filters work when only one dropdown is set? They work in WordPress 5.8.2 but don’t in 5.8.3
- Replace a single variable with add_filter
- Sending simple variable on single page to WP JSON
- How to exclude meta no index pages from wp_list_pages
- Ajax filter with loadmore button
- Query by pagename not Working
- Display featured image of post type category
- Delete post meta by serialized meta value
- get_filtered_term_product_counts – Get product terms if any products
- Getting info about selected posts using one WP_Query
- List all ACF field values across every post on one page
- Multiple Arrays for Custom Post Query using Boostrap accordions and ACF repeater fields
- Query to show average # of months all accounts with specific role have been active
- Woocommerce Related Product by 2 taxonomy
- Query doesn’t display text data with apostrophes
- Querying posts from wordpress with 2 or more conditionals
- SQL Query Search page
- Can’t get data from audio media
- Display Year and Month from custom field + Age Calculator
- insert thumbnail image from php script
- WP_Query count of different meta key values [duplicate]
- Masonry layout within the loop
- Fix incorrect related posts code snippet
- wp_query on search results page showing all results every time
- Changing regular db connection to $wpdb
- Variable ++ in query loop
- a problem in class in class-wp-hook.php
- Count custom posts type and filter by tag
- AJAX WP_Query’s order and orderby parameters not working
- Add adjacent post function inside custom recent post function
- How do I exclude the current post from the upcoming post query
- How do I display WooCommerce products in my query to rows of 3?