Skip to main contentSkip to footer

Modernize is a neat Premium theme that has a problem with Relevanssi. Relevanssi highlighting can cause problems on Modernize search results pages, with results getting wrong background color.

This problem is caused by the way Modernize truncates excerpts to certain length, set in the Modernize settings. It doesn’t care about HTML tags, so Modernize may cut the excerpt in the middle of a HTML tag inserted by Relevanssi, causing the markup to break.

Add this code to the theme functions.php to make highlighting work in Modernize:

add_filter('pre_option_'.THEME_SHORT_NAME.'_search_archive_num_excerpt', 'relevanssi_modernize_fix');
function relevanssi_modernize_fix($value) {
	if (is_search()) return 1000;
	return $value;
}

This makes the excerpt length 1000 characters on search results pages. If you use longer excerpts, adjust the value: it needs to be higher than you ever need (so make it 1000000 to make sure: the actual length of the excerpt is defined in the Relevanssi settings).

Your account

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

Search

Popular Resources

Indexing product codes with and without spaces

A Relevanssi Premium customer had a problem with product codes. The codes are in the format “ABC 100”, a group of letters and digits with a space in between. Users may search for the codes without the space, so the post should be found with “ABC 100” or “ABC100”. The……product can be found with either “ABC 123” or “ABC123” search * terms. This is applied to post content and titles. * * @param string $content The content to manipulate. * * @return string The content with the spaceless product codes added. */ function rlv_product_codes( $content ) { $pattern =…

Related Posts:

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