I am trying to query related posts.
I have the ID of a post of type "manufacturer" and i want to see all the related "reps" which are related through an intermediary post type
i've started with what I thought was a simple use of toolset_get_related_posts but it seems to return an empty array.
in the example code below, I know that the ID I am using has multiple related intermediary post types.
if you want to, you can see it here: hidden link
to do so, log in first by clicking here: hidden link
function count_related_reps() {
$current_id = 27277;
$connected_posts = toolset_get_related_posts(
$current_id,
'rep-manufacturer',
[
'query_by_role' => 'parent',
'role_to_return' => 'all',
'return' => 'post_object'
]
);
error_log(print_r($connected_posts,true));
}
add_action('init', 'count_related_reps');
any idea why the array is empty when it shouldn't be? I must be using the function wrong but I don't see how.
My issue is resolved now. Thank you!
apparently, should be:
'query_by_role' => 'child',