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

WooCommerce: Return only exact matches for SKU searches

…_sku custom field (because otherwise, SKU search will not find anything), and the search query must match the SKU exactly. Add this code to your site: add_filter( ‘relevanssi_hits_filter’, ‘rlv_sku_exact_match’ ); function rlv_sku_exact_match( $hits ) { global $wpdb; $post_ids = $wpdb->get_col( $wpdb->prepare( “SELECT post_id FROM $wpdb->postmeta WHERE meta_key = ‘_sku’ AND……)[‘object’]; return in_array( $hit_object->ID, $post_ids, false ); } ); return $hits; } Any searches that match an SKU in the database should only return the product matching the SKU. If you index product variation SKUs for the main product, the function above won’t work. When searching for product variation SKUs,…This little filter function works on relevanssi_hits_filter. When a search query is made that matches an SKU (or any other custom field, but SKUs are the most likely scenario here), only results that match the SKU will be returned. For this to work, Relevanssi must be set to index the…

Gmedia photo gallery tags
Gmedia photo gallery gives a false impression of working with Relevanssi, as you can see the gmedia_tag taxonomy appear in…

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