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

Membermouse
If you’re using MemberMouse to manage memberships on your site, having Relevanssi co-operate with MemberMouse is easy using the relevanssi_post_ok…
Spam search blocking
Spam searches are a common feature on WordPress sites. Spam bots make lots of useless queries. They hope sites display…
ACF: Indexing ACF fields for taxonomy terms

…) { if ( ! isset( $term->term_id ) ) { return $content; // not a taxonomy term, skip } if ( isset( $term->term_id ) && ! isset( $term->taxonomy ) ) { // this is excerpt-building, where the taxonomy is in $term->post_type $term->taxonomy = $term->post_type; } $post_id = $term->taxonomy . ‘_’……won’t index these taxonomy custom fields because taxonomy terms aren’t generally allowed to have custom fields, and the default get_post_meta() function doesn’t work on taxonomy terms. Getting the fields indexed requires a bit of custom programming. You need to add a function to the relevanssi_tax_term_additional_content filter hook that reads the…Advanced Custom Fields makes it possible to add custom fields to taxonomy terms. You can only do this with Relevanssi Premium because the free version of Relevanssi can’t index taxonomy terms. Here’s how you would create a category field in ACF. Suppose you set Relevanssi to index custom fields. 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