apply_filters( 'relevanssi_index_comments_exclude', bool $exclude, int $post_id )
Controls whether comments are indexed for a particular post.
Parameters
$exclude
(bool) If true
, exclude comments for this post. Default false
.
$post_id
(int) The post ID.
More information
This hook fires in relevanssi_get_comments()
where Relevanssi would fetch comments for the post so that they can be indexed. If this filter hook returns false
, the comments for the post are not indexed and the relevanssi_get_comments()
immediately returns an empty string.
This function would block comment indexing for the news
post type, while allowing comments for other post types:
add_filter( 'relevanssi_index_comments_exclude', 'rlv_no_comments_for_news', 10, 2 ); function rlv_no_comments_for_news( $exclude, $post_id ) { if ( 'news' === relevanssi_get_post_type( $post_id ) ) { return false; } return $exclude; }