I need to filter on a relationship. Only Buildings connected with the Customer Group relationship named "Eiendomsspar" should be retrieved. Is it possible?
$posts = toolset_get_related_posts(
get_the_ID(), //Post to query by.
'replace-your-relationship-slug, //Slug of the relationship to query by
'parent', //Name of the element role to query by.
1000, //Maximum number of returned results
0, //Result offset
array( //Additional query arguments
'meta_key' => 'wpcf-customer-group',
'meta_compare' => '=',
'meta_value' => 'Eiendomsspar'
),
'post_object', //Determines return type
'child', // which posts from the relationship should be returned
'title', //orderby: null, 'title', 'meta_value', 'meta_value_num'
'ASC' // $order 'ASC' or 'DESC'.
);
Where:
- Replace "replace-your-relationship-slug" with your original post-relationship slug
- Replace "wpcf-customer-group" field slug if required with your original custom field slug
- Replace the meta_value if required.
Can you please try and check if the solution I shared help you to resolve your issue.