The usage example documentation for the legacy and the new function seems to be the same. It also does not show how the query should be constructed to use all the arguments.
Could you please let me know how I need to modify the code below for the query to work in the new relationships version of toolset?
Initially, I'm trying to count all 'programming' posts that are children of the '$atts[child'] post. Later I'll try and introduce some meta queries as well but this is returning a white screen.
If you are getting a white screen it means you should find a fatal PHP error in your debug.log which would probably give a clue as to the specific problem.
The toolset_get_related_posts function was rewritten so that it is no longer required to pass all of the arguments (the documentation for the legacy version refers to that earlier version, rather than legacy Types relationships).
You need to provide the query_by_role, which, if you are trying to retrieve child posts would be the parent.
Most of the arguments are optional, but their use would look something like this:
$origin_id = $atts['child'];
$relationship_slug = 'breed-dog';
$child_posts = toolset_get_related_posts(
$origin_id, // get posts connected to this one
$relationship_slug, // in this relationship
array(
'query_by_role' => 'parent', // origin post role
'role_to_return' => 'child', // role of posts to return
'return' => 'post_id', // return array of IDs (post_id) or post objects (post_object)
'limit' => 999, // max number of results
'offset' => 0, // starting from
'orderby' => 'title',
'order' => 'ASC',
'need_found_rows' => false, // also return count of results
'args' => null // for adding meta queries etc.
)
);
Within the array of arguments you should supply the first two (query_by_role and role_to_return), the rest can be omitted (and can be supplied in any order).
Note that we have an internal ticket to update the limit option to accept -1 (like WP_Query, to mean no limit), but currently if you want no limit you would need to specify some large number.