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

Pin a post for all searches
Relevanssi Premium has tools for pinning posts for specific queries and all searches where the post appears, but what if…
Debugging slow searches

Reasonable expectations for Relevanssi searching speeds are measured in seconds. Relevanssi does not generally return results in milliseconds. On the other hand, the searches shouldn’t take more than few seconds in most cases. Multisite searches are a different thing: even if the searching is reasonably fast, searching across many sites……should be close to the number of posts found. If there’s a big difference, that’s often a performance problem. If your site does 3000 queries every time you search, that’s going to take time even if those queries are fast. (See Performance issues here for avoiding common pitfalls.) Meta query…

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