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

ACF: Indexing relationship content
If your posts include content from related posts using the Advanced Custom Fields relationship functionality, Relevanssi doesn’t index that content…
Adding a search form in the navigation menu

…the SearchWP Modal Search Form. As the name says, the plugin is from the SearchWP developer Jon Christopher, but it also works great with Relevanssi. This plugin can easily add a search feature to your navigation menu or a site header. The search form also works great on mobile devices….…header. That’s a good reference if you want to build a nice search form in the header. If your theme does not include a built-in search form and you’re not interested in building one yourself, one of the best plugin options is the SearchWP Modal Search Form. As the name…WordPress doesn’t make adding a search form in the navigation menu easy. It’s a popular request, though, and having access to the search in the site header is typical. Relevanssi itself doesn’t have opinions on the user interface. Some themes, like Twenty Twenty, include a built-in search feature in the…

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