relevanssi_index_content

apply_filters( 'relevanssi_index_content', bool $index, WP_Post $post_object )

Controls whether post content is indexed or not.

Parameters

$index
(bool) If true, index post content. Default true.

$post_object
(WP_Post) The post object.

More information

If you don’t want to include the post content in the search at all, the best way to stop that is by using this filter hook by adding this line to your theme functions.php:

add_filter( 'relevanssi_index_content', '__return_false' );

This will short-circuit the content indexing. Make sure you rebuild the index after adding the line. This will make indexing much faster, the index a lot leaner, and the search faster – but of course, with the price of losing the post content. But sometimes, that makes sense, and in those cases, this is the best way to stop Relevanssi from indexing the post content.

If you do that, you can also add this to stop content from being used in excerpts:

add_filter( 'relevanssi_pre_excerpt_content', '__return_empty_string' );

If you want to exclude post titles from the index, use relevanssi_index_titles for that.

If you want to block content from some posts, you can use relevanssi_post_content and return an empty string for the posts where you don’t want the content indexed.

You can also use the second parameter of relevanssi_index_content, introduced in 2.24.1, to control where the post content is included and where not. For example, to exclude the content for pages, you can use this:

add_filter( 'relevanssi_index_content', function( $index_content, $post_object ) {
  if ( 'page' === $post_object->post_type ) {
    $index_content = false;
  }
  return $index_content;
}, 10, 2 );