I’m trying to filter post types by another post type selected as custom field.
courses:
power
water
classes:
class1:
title : class1
parent_course : power
my code in single-course.php:
$id = get_the_id();
$classes = get_posts(array(
‘numberposts’ => -1,
‘post_type’ => ‘class’,
‘meta_key’ => ‘parent_course’,
‘meta_value_num’ => $id
));
but no data retrieved or all classes without any filtering retrieved.\
any idea?
thanks
It depends on what type of field parent_course is. The query you need to use will depend on what type of field it is and the way that field stores data in the DB https://www.advancedcustomfields.com/resources/query-posts-custom-fields/