You’re almost there — you just need to add the comparison to your meta query:
$args = array(
'post_type' => 'product',
'meta_query' => array(
array(
'key' => 'artist',
'value' => $artistID,
'compare' => '='
)
)
);
https://codex.wordpress.org/Class_Reference/WP_Meta_Query
Remember to filter $artistID
before accepting it in your query!
Related Posts:
- Can wp_query return posts meta in a single request?
- Getting attachments by meta value
- WordPress altering my custom query, How to fix it?
- Group WP_Query by meta_key date
- exclude posts with a specific custom field and value
- How to make Meta Query case sensitive?
- Display custom field meta outside loop, site wide
- Fetch Record based on meta key dates
- how to make members list directory through wordpress post custom meta key.
- Large AND OR query timing out
- Order WP_Query results by meta key value in custom query
- Display post meta conditionally based on it’s value
- How do i create a custom post query when the meta value is an array?
- Trouble with serialized metadata
- Query against multiple locations within single custom post type post
- Meta key in wp_query bug?
- Sorting Posts with meta value not working
- Custom Search Query – include only custom fields and title
- Extend search query to search meta keys values based on search string
- order by numeric value for meta value
- How can I use order_by to order by two meta_keys without excluding posts that don’t have those keys initialized?
- What is the most efficient way of querying posts based on visits and date for current day?
- WP_Query displaying ALL posts
- How to count post meta key values for all posts in database
- Sorting Posts by custom field
- Order posts by date and then by custom field
- How should I use posts_where to change meta_value from a string to integer?
- How can I create a WP_Query that returns posts where one meta_value
- WP Meta Query for some meta (array) values
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- How to get sum of meta_values of a meta_key in wp_query according to conditions
- meta_key and meta_value not working together
- How can i make WP_Query return post image and categories?
- How add a custom posttype name using ACF field to a query post array
- Ordering Posts Type A by Custom Fields of related Post Type B
- Query Posts depends on custom field inside repeater field using acf
- Get meta info related to current post
- Select from wp_post and multiple meta_value from wp_postmeta
- Search Posts with Custom Fields as query
- Get attachment by meta_key value
- Meta_query with multiple keys and multiple values
- meta_query BETWEEN, but the range is stored in the custom field
- Get a list of posts with associated meta_value
- WordPress Comments sort by custom meta key
- Understanding the orderby in WP_Query?
- How to list custom fields as headers and list all pages sharing that custom field under it?
- How do I query for posts by partial meta key?
- How to increase load time of an archive/search page (WP_Query)
- get_post_meta in WP_Query
- Search posts missing a particular custom field
- WordPress query posts with multiple post_meta data
- Conditional operator OR not working with custom fields
- How do I check if an article is popular this week?
- WP_QUERY with group by with custom fields
- Intiger meta value with ‘>=’ returns posts with lower value
- Posts query according to meta box date
- create metabox to activate slider
- Query posts using less than
- Excluding posts with certain value of meta_key keeping posts without that meta_key
- Query only displays one page_id
- Query using string from custom field as array value
- How to show list of posts with custom field value (a date) that are coming soon
- Sort by custom field that is an array?
- WP_Query meta compare must include ALL array values
- meta_query weird behaviour, static int will work, but not user data
- Woocommerce Shortcode which displays a table with product data
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- wp query to use both author id and meta_query
- Query posts by post type, author and post meta
- How to use the Term Object from a custom select field in a query
- Sort by price wpdb
- Custom filter from post meta
- Query post by Category and custom file (ACF)
- Problem with my loops
- update_post_meta performance in a loop woocommerce
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- ACF Post Object meta-query by title not ID
- Sort posts on custom field AND after that sort on date?
- From admin edit user page query either the user_nicename or username field value of the user profile being edited or viewed
- WP_Query sort by meta_value_num or date
- I can’t get post based on its postmeta value and key
- Saving custom fields for WP_Query to retrieve
- How to show all the associated posts with specific date of data metabox?
- Creating Ordered Query using Meta_key
- WP_Query with Pagination and orderby meta_value_num showing duplicates
- WP_Query Posts by Metadata from Option Tree
- Custom search (wp query by custom fields)
- How to get several fields from wp_query?
- How do I display posts with specific value in a custom field into my loop?
- WP Query to order posts by multiple meta fields
- query_posts with sorting on a custom datestamp
- How to count post meta key values for all posts in database
- query by meta value then date and not empty meta value
- Querying meta values within an array
- Display all custom meta field values from the database using ACF Repeater
- wordpress sorting using array merge by price in ascending order but price with 0 must be show last
- Query posts by meta value and sort by another meta key
- WP_Query – order with usort by custom meta
- WP_Query sort by ACF date field (newest first) with blank dates first
- How to include custom fields in wordpress search