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

Indexing term slugs
I have a term who name is for, example, Great Blue Trojans. The slug is GBT.I want to be able…
Genesis
In some cases, Relevanssi requires modifications to the search result template for the search results to work properly (in particular…
Indexing image captions for the posts

…can index it. The image captions for the images in the Media library is stored in the post excerpt, so what needs to be done is to fetch the post excerpts and include them. The actual filter is straightforward: add_filter( ‘relevanssi_content_to_index’, ‘rlv_add_attachment_excerpts’, 10, 2 ); /** * Indexes attachment excerpts……If you want to index the image captions for the posts where the images are used, that’s easy if the captions appear on the page: Relevanssi will index those captions as well as the other text from the post. However, if the captions don’t appear on the page, you need……extra steps in order to read in the captions. The trick is to add an indexing filter on the relevanssi_content_to_index filter hook that will find all the attachments for a post, fetch the desired data out of the attachments and add that data to the parent post content so Relevanssi…

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