I found a solution. The issue was with my configuration based on the combination of Trellis/Bedrock/Sage by Roots.
I was putting the above-mentioned code into the setup.php
, but it should go into the filters.php
(duh…). Also, I had to inline the function as such:
add_filter('acf/fields/relationship/result/name=about_team_profiles', function($title, $post, $field, $post_id) {
$first_name = get_field('profile_first_name', $post->ID);
$last_name = get_field('profile_last_name', $post->ID);
$title = $first_name.' '.$last_name;
return $title;
}, 10, 4);
The fields are not subfields and I double-checked the field names as well. Even if I return a hard-coded dummy value it doesn’t show up and I only get null.
So it seems like the filter is activated but somehow the return $title
is not getting through at all.
Any ideas on how to debug this?