Support

Account

Home Forums General Issues Relationship Field Filter by \'last_name\' Reply To: Relationship Field Filter by \'last_name\'

  • Looking at the filter you posted above

    I also changed the variable names to better reflect what is getting passed to your function.

    
    add_filter(
      'acf/fields/relationship/result/key=field_565de210b1c8c',
      'my_relationship_result', 10, 4);
    
    function my_relationship_result($title, $post_object, $field, $post_id) {
    	$lname = get_field('last_name', $post_id);
    	$fname = get_field('first_name', $$post_id);
    	// instead of adding, replace it
    	$result = $lname.', '.$fname;
    	return $result;
    }