I have two post types. Courses and Course Categories. Courses are children of Course Categories.
When I'm on a course page, I want to create a sub menu that lists all the current course' siblings by using the logic "Show all the courses that have the same parent as the current course"
I've managed to get the correct course category ID with:
$parent_id = wpcf_pr_post_get_belongs(get_the_ID(), 'course_category');
But I am unable to get a list of siblings to generate. I've tried the following:
$childargs = array( 'post_type' => 'course', 'numberposts' => -1, 'meta_key' => 'wpcf-description', 'orderby' => 'meta_value', 'order' => 'ASC', 'meta_query' => array(array('key' => '_wpcf_belongs_course_category_id', 'value' => $parent_id)) ); $child_posts = get_posts($childargs); foreach ($child_posts as $childpost) { echo $child_post->post_title; echo $child_post->ID; }
This produces no results.