Skip Navigation

[Resolved] help using toolset_get_related_posts

This support ticket is created 4 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 1 voice.

Last updated by BrandenT2154 4 years, 1 month ago.

Author
Posts
#1870933

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.

#1870945

My issue is resolved now. Thank you!

apparently, should be:
'query_by_role' => 'child',