Dear Support,
while trying to resolve relationship fields into their post title using the filter: relevanssi_custom_field_value
it always returns Updating failed. The response is not a valid JSON response.
I’ve tried following your example on https://www.relevanssi.com/user-manual/filter-hooks/relevanssi_custom_field_value/ but even returning an empty array (or returning the $meta_value directly) does not work.)
I would be happy to recieve any help or guidance. It seems to me the documentation for the filter might not have been updated?
WP: 6.5.2
PHP: 8.2.18 (Supports 64bit values)
Server: Apache/2.4.59 (Unix)
Plugin: 4.22.2
With kind Regards
Ordo
Ps. the Code:
add_filter( 'relevanssi_custom_field_value', 'rlv_connect_relationships_in_fields' );
function rlv_connect_relationships_in_fields( $meta_value, $meta_key, $post_id ) {
$new_meta_values = array();
switch ($meta_key) {
case 'buecher':
case 'autoren':
foreach ( $meta_value as $related_post ) {
$new_meta_values[] = ' ' . get_the_title( $related_post );
}
break;
case 'date':
foreach ( $meta_value as $date ) {
$new_meta_values[] = substr($date, 0, 4);
}
break;
default:
$new_meta_values[] = $meta_value;
}
return $new_meta_values;
}
