relevanssi_excerpt_specific_custom_field_content

apply_filters( 'relevanssi_excerpt_specific_custom_field_content', array $custom_field_content, string $post_id )

Filters the custom field content used for excerpts.

Parameters

$content
(array) The custom field content in an array, where array keys are the field names and the values are the custom field content.

$post_id
(int) The post ID.

More information

This hook is the same as relevanssi_excerpt_custom_field_content but used when the “Create custom field specific excerpts” setting is used. With this setting, the custom fields are handled separately, so Relevanssi can tell which custom field is used for the excerpt.

This filter hook lets you modify the custom field values used for the excerpts. The filter gives you an array of custom field values indexed by the key. You can modify the array freely. For example, you can use this filter hook to modify custom field values before they are used for excerpts, or remove them completely:

add_filter( 'relevanssi_excerpt_specific_custom_field_content', function( $fields ) {
  $fields['exclude_this_field'] = '';
  $fields['modify_this_field']  = str_replace( 'unwanted text', 'better text', $fields['modify_this_field'] );
  return $fields;
} );