Continue reading WPML: Replacing posts with translations

WPML: Replacing posts with translations

Here’s a different approach to WPML searching. By default, you have two options. You can include posts in all languages in the results, or you can only use the current language. This solution checks for matches also in other languages. If Relevanssi finds any, this script then replaces them with the translated posts. You get…

Read more WPML: Replacing posts with translations 0 Comment on WPML: Replacing posts with translations
Continue reading Searching for all descendants of a page

Searching for all descendants of a page

If you want to restrict a search to a page and all it’s children, you can add a post_parent parameter to the search, and that’s it – but that only includes the direct children of the page. What if you want to include page, it’s children, all the grandchildren and their children? In that case,…

Read more Searching for all descendants of a page 0 Comment on Searching for all descendants of a page
Continue reading WooCommerce: Return only exact matches for SKU searches

WooCommerce: Return only exact matches for SKU searches

This little filter function works on relevanssi_hits_filter. When a search query is made that matches a SKU (or any other custom field, but SKUs are the most likely scenario here), only results that match the SKU will be returned. In order for this to work, Relevanssi must be set to index the _sku custom field…

Read more WooCommerce: Return only exact matches for SKU searches 1 Comment on WooCommerce: Return only exact matches for SKU searches
Continue reading Wishlist Member: Sorting the posts by membership levels

Wishlist Member: Sorting the posts by membership levels

Someone wanted a way to prioritize posts that are targeting particular Wishlist Member membership level. The basic implementation here is simple: create a relevanssi_hits_filter function that will sort the posts by the level. There’s a trick to this, though, as Wishlist Member does not provide a way to check the level of one post. There’s…

Read more Wishlist Member: Sorting the posts by membership levels 0 Comment on Wishlist Member: Sorting the posts by membership levels
Continue reading Showing only one recurring event

Showing only one recurring event

Some event calendar plugins do recurring events by creating many posts. That’s fine, until those cloned posts fill up your search results. This function, added to your theme functions.php, will only show one of each post with the same title, and will take the one with the first date. The date is checked from _EventStartDate…

Read more Showing only one recurring event 2 Comments on Showing only one recurring event
Continue reading Category filter for search results pages

Category filter for search results pages

Sometimes it’s nice to have a category filter on the search results pages: a simple dropdown where you can choose the category you want to show. It’s easy to create one using wp_dropdown_categories(), but on a search results page that’s slightly problematic, as it’ll include all categories, not just those included in the search results.…

Read more Category filter for search results pages 30 Comments on Category filter for search results pages
Continue reading Premium 1.10.5

Premium 1.10.5

Couple of bugs found, a significant improvement in the settings page and couple of new features. That’s what this version is made of. Here’s the changelog: Support for WP Table Reloaded and TablePress. Tables created with these plugins will now be expanded and the content indexed by Relevanssi. Relevanssi now adds spaces between tags when…

Read more Premium 1.10.5 9 Comments on Premium 1.10.5
Continue reading Search results in random order

Search results in random order

Do you want to order your search results in random order? Here’s how: Put this code in your functions.php and the search results will appear in random order. You can also do this: However, both of these solutions only work if all the search results are on the same page. If the results span multiple…

Read more Search results in random order 1 Comment on Search results in random order