Skip to main contentSkip to footer

Here’s how you can disable Relevanssi Light for a particular post type. The example is shop_order from WooCommerce: you’ll need this if you use the legacy order storage. Otherwise, Relevanssi Light will stop the admin order search from working.


add_action('init', function() {
	add_filter( 'posts_search', function( $request, $query ) {
		if ( 'shop_order' === $query->query['post_type'] ) {
			remove_filter( 'posts_search', 'relevanssi_light_posts_search', 10 );
			remove_filter( 'posts_search_orderby', 'relevanssi_light_posts_search_orderby', 10 );
			remove_filter( 'posts_request', 'relevanssi_light_posts_request', 10 );
		}
		return $request;
	}, 1, 2 );
}, 11 );

Your account

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

Search

Popular Resources

Italian plurals

…or “che”, the ending is changed to “ga” or “ca”, respectively. Then if the word is over three letters long, a final “a”, “e”, “i”, or “o” is stripped. Now plural and singular forms are considered the same in the search. Remember to rebuild the index after adding this function!…

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…

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