In the WP Docs you can find the answer.
I have not tested this snippet, but it should become something like this:
$args = array(
'post_type' => 'product',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'product-ean',
'value' => 123,
'compare' => '=',
),
array(
'key' => 'item-ean',
'value' => 123,
'compare' => '=',
),
),
);
$query = new WP_Query( $args );
Related Posts:
- Using Query Posts With Multiple Post Types And A Taxonomy
- Can’t sort order of wp_query with 2 meta keys
- Display custom post type from dynamic custom field
- Get posts between custom dates
- 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
- WP_Meta_Query object with conditionals
- WordPress custom post type
- Custom Query With Multiple Meta Key Value
- Querying meta values within an array
- Meta query with boolean true/false value
- Get post with multiple meta keys and value
- Mixing regular and custom post types (with meta_query) on home page
- Fail to compare dates in meta_query
- WP_Query() show posts that end later than today
- Custom post type archive 404’s with paginate_links
- Ordering posts having multiple post-meta date fields
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- Display Custom Post Type Fields
- how to group custom post type posts by custom taxonomy terms
- I can’t set meta_key in my custom post type query
- order by meta_value serialized array
- How to get the parent’s taxonomy?
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Comparing timestamps in meta query doesn’t work
- Combine tax_query and meta_query in WP_Query
- query order by date on custom type: wrong order
- Used with meta_query in query_posts works slowly
- exclude custom post type by meta key in wp_query
- Query for posts in 2 taxonomies
- Conditionally Query Custom Post Types by Post Meta for Blog Home Page?
- Display custom post types with custom date field value (before today) & order by custom date field
- Custom query shows custom post types in trash
- Multiple post type queries (with specific arguments for each)
- Is it possible to apply a meta_query to one specific post type in a query with multilple post types?
- WordPress Orderby Numeric Value Not Working
- orderby in custom WP Query does not work
- WP_Query: include custom post type only with specific meta value
- Query/list all terms and their custom post count
- Get latest 3 posts from multiple CPT in one query
- how to make members list directory through wordpress post custom meta key.
- Why is this query not working? (Standard posts + custom post type)
- Polylang non-default language ignores tags in WP_Query
- WordPress request fiter order by related post’s post_title
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Different Ways to Query Custom Post Types?
- Possible to filter custom post type with multiple meta data?
- How to display Related Posts based on number of taxonomy terms matched
- How to make WP_Query not to show irrelevant posts?
- Loop for custom post types filtered by a taxonomy
- WP_query – Filter by tax_query and meta_query using multiple select
- How to get specific post meta by title or id
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- Querying multiple values from a single key
- Pagination not working on custom query on a page
- FacetWP paging custom wp_query
- $post->post_meta not pulling any post in wordpress/php
- Can’t change posts per page in WordPress Post Type Query
- postsperpage value not being applied
- Create a WP_Query where if the first value of the first row is equal to the second compare other value
- Sorting by meta_key different to search criteria?
- Using WP meta query to show custom post types by a start and finish date
- HM CMB: Post Select Field for CPT ID
- Custom Post Type Query W/Category Dropdown
- Find Posts based on Child Post value
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- How do i create a custom post query when the meta value is an array?
- build child and anchestor three from post parent
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- meta query condition don’t work
- Custom query result empty on page 2
- Show posts from WP Custom Post Type selected from a field in a metabox
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- meta query multiple values for the same key
- How to get post by meta value
- Custom post types – meta_query: search lesson which starts sooner
- How do I get all authors posts of a custom post type outside loop
- minimize wp_query call to database
- Meta_Query refuses to return results
- Linking posts together with Advanced Custom Fields “both ways”
- Not able to get my custom search result using meta_query and tax_query together?
- How to get Current week and current date record wp query
- How to get post meta for custom post type and taxonomy
- Querying, storing, and using data from 2 separate custom post types
- get_post_meta for Custom Post Type ( CPT )
- Query events post type after current date and timezone
- Conditional posts in WP_query for search
- Imported Content Doesnt Show Up On Frontend
- Custom Post Type meta oembed html output resulting in WSoD
- Filter RSS feed for custom post type to events for next 7 days only
- Query Posts From Multiple Post Types
- Return only custom post types for the page, not all
- send user to first page of results when reposting to page?
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- How to exclude certain portfolios from a loop
- Display ACF object field data using Elementor Custom Query
- WP_Query() displaying past post / event
- WP Query Conditionally query meta and taxonomy
- Assign a tag to custom post type using a query