I am trying to: get connected posts (relationships)
This is the code:
$dwdev_exercise_id = 5455; // <= This is a valid ID in our site;
add_action( 'init', function() use ( $dwdev_exercise_id ) {
$relations = toolset_get_related_posts( $dwdev_exercise_id, 'exercise', [ 'query_by_role' => 'parent' ] );
QM::debug( $relations );
Here is an example format that makes it easy to manage all the necessary arguments:
// get related posts
$query_by_element = 5455; // ID of post to get the relationship from
$relationship = 'relationship-slug'; // relationship slug
$query_by_role_name = 'parent'; // $query_by_element is a parent in this relation
$limit = 1000; // set limit to the number of results returned
$offset = 0; // set number of results to skip
$args = array(); //nothing needed
$return = 'post_id'; // Return post IDs
$role_name_to_return = 'child'; // We want related children.
$get_results = toolset_get_related_posts(
$query_by_element,
$relationship,
$query_by_role_name,
$limit,
$offset,
$args,
$return,
$role_name_to_return
);
Note: Please change the 'relationship-slug' and the roles like 'parent' and 'child', as per your requirements.
We had a busy forum queue during the holidays, but your two other tickets have been replied to now. Thank you for your patience.