apply_filters( 'relevanssi_excerpt_post', boolean $make_an_excerpt, WP_Post $post, string $query )
Controls whether Relevanssi creates an excerpt for a post or not.
Parameters
$make_excerpt
(boolean) If true
, generate an excerpt for this post. Default true
.
$post
(WP_Post) The post object.
$query
(string) The search query string.
More information
This filter hook is applied in relevanssi_add_excerpt()
, the function used to replace the $post->post_excerpt
with the excerpt Relevanssi generates. If this filter hook returns true
for the post, Relevanssi then runs relevanssi_do_excerpt()
for the post, creates an excerpt, and stores it in $post->post_excerpt
. If this filter returns false
, no excerpt is created and $post->post_excerpt
contains the original excerpt.
No matter what happens, Relevanssi still copies the original excerpt to $post->original_excerpt
, so if you need it for some reason, you can rely on it existing even if Relevanssi skips creating the excerpt.
To disable excerpts for the post with the ID 14, you can add this to your site:
add_filter( 'relevanssi_excerpt_post', function( $make_excerpt, $_post ) { if ( 14 === $_post->ID ) { $make_excerpt = false; } return $make_excerpt; }, 10, 2 );