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

Toolset Views
Relevanssi works fine with Toolset, thanks to a lot of compatibility code the makers of Toolset have included in it…
EmbedPress autoembeds
EmbedPress has an auto-embed feature that tries to embed all URLs found in posts. This can cause problems with Relevanssi:…

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