relevanssi_excerpt_custom_field_content

apply_filters( 'relevanssi_excerpt_custom_field_content', string $content, int $post_id, array $custom_fields )

Filters the custom field content used for excerpts.

Parameters

$content
(string) The custom field content as a single string.

$post_id
(int) The post ID.

$custom_fields
(array) An array of custom field names used.

More information

If you use the “Create custom field specific excerpts” setting, this filter hook is not used. Use relevanssi_excerpt_specific_custom_field_content instead.

In order to display custom field content in the excerpts, Relevanssi adds the custom field content to the end of the post content in relevanssi_do_excerpt(). This way, the custom field content can be used as source material for the excerpts.

To enable this functionality, you must enable the “Use custom field content for building excerpts” setting on the Relevanssi Excerpts and highlights settings page. The custom fields used are the same as those used for indexing.

If you want to modify the way the custom field content is presented, you can use this filter hook.

With that, you can, for example, rebuild the whole content. If you, for example, only want to use one field:

add_filter( 'relevanssi_excerpt_custom_field_content', 'rlv_just_use_one_field', 10, 2 );
function rlv_just_use_one_field( $content, $post_id ) {
  return get_post_meta( $post_id, 'use_only_this_field', true );
}