Skip to main contentSkip to footer

Sometimes there’s a need to disable the in-page highlighting on specific pages. Perhaps the feature works fine on most pages, but some pages have content that is broken by the highlighting.

In theory, disabling the feature is very simple: remove the relevanssi_highlight_in_docs filter function from the the_content hook for that page. In practise, getting it to work requires good timing so that you remove the filter hook after Relevanssi sets it but before it is run.

Add this function to your site to fix this problem:

add_action( 'parse_query', function() {
    global $wp_query;
    $excluded_page_ids = array( 1, 2, 3 );
    if ( in_array( $wp_query->queried_object_id, $excluded_page_ids, true ) ) {
        remove_filter( 'the_content', 'relevanssi_highlight_in_docs', 11 );
  }
}, 2 );

List the page ID numbers for the excluded pages in the $excluded_page_ids array.

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

YITH Badge Management
The Premium version of YITH Badge Management has a search feature for badges. Using Relevanssi breaks that badge search. Fortunately,…
Indexing attachment file names
Relevanssi has been working nicely for the normal usecase. But how does one setup indexing of attachment files. When someone…

Related Posts:

Currently there are no related posts available.

Comment Section:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed