I have a “taxonomy” field for a post, which I’m using to link a post_type (article) to another post_type’s (course) categories.
How can I use the meta_query to get all the articles in one course category?
I’m using
$args = array(
'posts_per_page' => $num,
'post_type' => 'post',
'meta_query' => array(
'key' => 'segment',
'value' => $segment_id,
'compare' => 'LIKE',
);
);
return get_posts( $args );
where $segment_id is the tag_id.
This works except it’s returning articles with category ID 3, as well as 34 because of the LIKE clause.
'compare' => 'IN'
Does not seem to work.
I’m unfamiliar with how this is stored in the database.
Any help is appreciated.