Continue reading GeneratePress: Query Loop

GeneratePress: Query Loop

Relevanssi doesn’t work automatically with the Query Loop block in GeneratePress and GenerateBlocks. Fortunately, the solution is simple: the Query Loop block has a filter hook for adjusting the query parameters, and you can use that filter hook to enable Relevanssi. Add this to your site: add_filter( ‘generateblocks_query_loop_args’, function( $query_args,…

Read more GeneratePress: Query Loop 0 Comment on GeneratePress: Query Loop
Continue reading Gutenberg Full Site Editing

Gutenberg Full Site Editing

…core WP excerpt block does not allow Relevanssi highlights in excerpts. It will display Relevanssi excerpts (restricted to the excerpt length in the block settings – make sure the setting in the block is higher than the Relevanssi excerpt length setting), but no highlights will be visible because all the…excerpts are passed through wp_trim_words() which removes HTML tags. This function can be used to overcome this limitation: add_filter( ‘wp_trim_words’, function( $text, $num_words, $more, $original_text ) { global $post; if ( isset( $post->relevance_score ) ) { return $post->post_excerpt; } return $text; }, 10, 4 ); If the post has the……relevance_score attribute set – which should only happen within a search context – this function will cause the wp_trim_words() to return the original post excerpt. With Max Mega Menu, the function above will add the excerpts to the menu items. You can avoid that: add_filter( ‘wp_trim_words’, function( $text, $num_words, $more,…

Read more Gutenberg Full Site Editing 2 Comments on Gutenberg Full Site Editing
Continue reading Martfury

Martfury

…you want to include user profiles and taxonomy terms in the search, and not products and other posts, those non-post items won’t appear correctly in the search. The permalinks will be wrong. That’s something you can’t fix with a simple filter hook, and instead you need to replace the whole……search. Add this to your site: add_action( ‘wp_loaded’, ‘rlv_replace_martfury_search’ ); /** * Unhooks the Martfury search and replaces it with our custom search. */ function rlv_replace_martfury_search() { global $wp_filter; unset( $wp_filter[‘wc_ajax_martfury_search_products’]->callbacks[10] ); add_filter( ‘wc_ajax_martfury_search_products’, ‘rlv_instance_search_result’ ); } /** * Custom replacement for the dropdown search. Includes all post types in…

Read more Martfury 0 Comment on Martfury
Continue reading Total

Total

…the search results, Total will block them from appearing in the search results as well. The solution for this is fortunately simple. Add this to your site: add_filter( ‘relevanssi_modify_wp_query‘, function( $query ) { $query->set( ‘post_type’, ” ); return $query; } ); This simply wipes out the post_type parameter, leaving it……up to Relevanssi to choose which post types are shown and which are not. If you want to, you can specify the post types you want to include in the parameter. For example to only shows pages and users, you can use: add_filter( ‘relevanssi_modify_wp_query‘, function( $query ) { $query->set( ‘post_type’,…

Read more Total 1 Comment on Total
Continue reading Flatsome

Flatsome

…can do. First, make sure the “Search Product SKU” setting in Flatsome is disabled. Then set Relevanssi to only index the products, not product variations, but make Relevanssi index variation SKUs for the main product. Then we need to modify the Flatsome Ajax Search function above like this: function rlv_flatsome_search_function(…Posts and pages on the product search results The Flatsome theme, when combined with WooCommerce, has a product search results page that can also show posts and pages. That doesn’t work with Relevanssi out of the box, but fortunately can be made to work. The function that adds the functionality……for posts and pages. If the live search does not work Flatsome has a built-in live search that should work with Relevanssi without modifications, but in case it doesn’t (for example searching for partial SKUs doesn’t work correctly even though it works in the Relevanssi admin search), you can add…

Read more Flatsome 0 Comment on Flatsome
Continue reading Divi

Divi

…and you should see Relevanssi-generated excerpts in the search results pages. Enable the “Use excerpts when defined” setting to see Relevanssi-generated excerpts. Avoiding indexing menus If you have menu blocks inside your posts, Relevanssi will index those menu contents as part of every post with the menu. That’s not very……excerpts Divi doesn’t use the default excerpts but instead truncates the beginning of the post and shows the first 270 characters. That means Relevanssi-generated excerpts don’t show up at all. However, you can configure Divi to show Relevanssi excerpts. Just enable the “Use excerpts when defined” setting in Divi settings,…

Read more Divi 86 Comments on Divi
Continue reading Avada

Avada

…probably in the Avada settings. It’s best to empty that option. If you have not chosen any post types in the Avada settings, Avada will leave the control of the post types to Relevanssi, which will then show only those post types you’ve chosen to include. Fixing excerpts Avada uses…Avada is one of the most popular WordPress themes on the market. All post types are not found Avada has search settings, including a list of post types to show in the results. If your Avada search is not showing all post types, attachments or user profiles, the problem is……as this. All you need to do is to add this function to your site, and you should have working Relevanssi-generated custom excerpts. No results Avada adds a fs parameter to the search. I don’t know what it does but sometimes it breaks the search completely. You can fix this…

Read more Avada 48 Comments on Avada
Continue reading Modernize

Modernize

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…

Read more Modernize 0 Comment on Modernize