Hi
I set up a website with:
– pages which describe methods
– custom post type “team” with team members
Then I used ACF to set up a relationship with type “article”
on a method-page I can link one or more team members to this page.
On the page I list the matching team members, this works perfectly.
But now to my problem:
I have a page which lists all team members with the use of WP_Query.
How is it possible to get the matching method/s per team member?
Example:
Method “Wellness”: Has person A & B linked
Method “Massage”: Has person B & C linked
Page “Wellness”: Lists persons A & B
Page “Massage”: Lists persons B & C
Page “Team”:
Person A -> Show “Wellness”
Person B -> Show “Wellness & Massage”
Person C -> Show “Massage”
OK, I managed to solve it by myself… the main problem was, that I used the name of the custom post type instead of the name of the ACF-relationship-field.
$methods = get_posts(array(
'post_type' => 'page',
'meta_query' => array(
array(
'key' => 'persons', // name of custom field
'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
));