My client’s site houses a lot of WooCommerce products. Many of which include the & symbol in the title. I’ve indicated for the index to keep & symbols in the search query, this brings up some results, but not them all.
When searching for a query such as “G&G” via the admin 180 products are found. When searching via the frontend, 3 products are found. I’ve taken an example of a product which appears in the admin but not the front end & inserted it into the debugger. The phrase G&G appears, but later on in the string than the actual title, heres an example:
how Relevanssi sees the post
The title
1500rd drum g&g magazine pcc45The content
1500 1500rd drum g&g information mag magazine manual pcc45 product roundsCustom fields
08 198 gg
How it is in the database
G&G 1500rd Drum Magazine For PCC45 Product Information – g&G manual drum mag for pcc45 1500 rounds
I’m not sure it matters where the phrase is found in the title? I also have no idea why the title appears to differ from the title of the actual product post?
I’ve had a play with several settings in the index & search, but nothing seems to make these products appear. Have you got anything I can try?
Thanks
Please, advise if it’s possible to exclude certain Woocommerce product categories from the frontend search results using Relevanssi plugin.
How to?
Thank you.
]]>Hi Mikko,
im trying to filter results alphabetically by post title. I read the documentation and using the string
add_filter( ‘relevanssi_orderby’, function( $orderby ) { return ‘post_title’; } );
add_filter( ‘relevanssi_order’, function( $order ) { return ‘asc’; } );
But nothing happen.
Any suggestions ?
Kind regards,
Antonio
]]>Hello – Relevanssi stops my select2 search for a metabox ‘post’ field, configured as a custom user field. All the items list, it just does not search.
After some debugging, I realise it is one of these issues:
1. I have custom fields turned on. But I am unable to switch it to ‘none’. As upon page reload it returns to ‘some’.
2. I also have ‘_bricks_page_content_2 ‘ saved in the list of custom fields to include in the index box. And have the same issue as trying to switch custom fields from ‘some’ to ‘none’ – the ‘_bricks_page_content_2 ‘ cannot be deleted and returns.
3. Either the ‘Index the post author display name’ or ‘Index the post excerpt’ being toggled on.
Can you let me know if you can replicate this issue and which option was the cause?
]]>Hello – using the Relevanssi free plugin am I able to customize the search results excerpt formatting?
If not, could you suggest a plugin that will do this for me?
Thanks!
]]>I am using the live search on this development site and I have amended the search-result.php file so it shows an image and price for the products. Is there a way I can do this without changing core files?
Thanks
]]>Hi there,
Since trashed posts by default are not indexed, this snippet destroys product search in the trashed page. I prefer not to index trashed posts, but instead not activate Relevanssi on the trashed products screen. Maybe you should add a note about that at the snippet page.
I changed line 3 to:
if (isset($query->query_vars['product_search']) && $query->query_vars['post_status'] != "trash") $ok = true;
]]>
I have been looking through the Relevanssi documentation and previous support tickets to figure out this issue, but all of my attempts have been unsuccessful. I am trying to ignore content that is found in specific custom Gutenberg blocks from being indexed by Relevanssi because our search results are being populated with posts that are irrelevant and only appear because they include the searched term in a few specific blocks that aren’t really part of the post’s pertinent content.
First I tried using the relevanssi_block_to_render hook to return null if the block is one of the ones we want to ignore:function relevanssi_no_index_blocks( $block ) {
$blocks_to_ignore = array( 'rcp-accordion', 'rcp-faqs', 'rcp-testimonials' );
if ( in_array( $block['blockName'], $blocks_to_ignore ) ) {
return null;
}
return $block;
}
Then I tried using the relevanssi_rendered_block hook to change the content of those same blocks to be an empty string before Relevanssi finishes indexing the content:function relevanssi_empty_out_block_content( $content, $block ) {
$blocks_to_ignore = array( 'rcp-accordion', 'rcp-faqs', 'rcp-testimonials' );
if ( in_array( $block['blockName'], $blocks_to_ignore ) ) {
$content = '';
}
return $content;
}
I also updated the markup of these blocks to add a “relevanssi_noindex” class to the block output and I manually added that class to the blocks in the Gutenberg editor.
None of these measures fixed the issue. I cleared cache and rebuilt the Relevanssi index each time I tried one of these approaches. What am I doing wrong? How can I accomplish what I’m trying to do here? I still want these posts to be indexed, I just don’t want the text/terms inside of these specific blocks to be indexed with the post because I don’t want posts to be displayed in search results if the only place in the post the search term is found is within these three blocks. Thanks for your help!
]]>We’ve just started using Relevansii plugin (recommended by Breakdance support). We’re using it to exclude woocommerce products from search which works brilliantly. However now, when we are searching a word, for example “asbestos” in the website search bar, it only shows a few pages that have that word in the page title, but not all pages that have that word in the title shows. Could advise on how to get it to show? (we’re not technical or developers).
]]>Hi,
I have been using Relevanssi in multiple projects but for a first time I am facing problems. I would like to use relevanssi for a better search in web shop. When Relevanssi is activated search plugin won’t find anything. There are articles in the index but no keywords. Theme is Generate Press.
]]>Hi there,
I’m getting this intermittent – as in, it happens for some search terms but not for others – error when searching in the front-end:
Unsupported operand types: int * string in /blahblahblah/public_html/wp-content/plugins/relevanssi/lib/search.php:918
If I do some debugging of that code:
$weight = $post_type_weights[ 'post_tagged_with_' . $tax ] ?? null;
write_log($weight); // $weight is null at this point
if ( ! $weight ) {
$weight = $post_type_weights[ $tax ] ?? 1;
}
write_log($weight); // but it's still blank now, and that's because $post_type_weights looks like: Array
(
[post_tag] => 0.75
[category] =>
)
// so if I add something like this:
if ( ! $weight ) {
$weight = 1;
}
// then the error doesn't happen, but otherwise doing this throws that int * string error:
$match_object->taxonomy_score += $count * $weight;
Any ideas, please? As I say, if I add a hack to force $weight = 1 then I can get around it, but I don’t want to put my ugly code in your marvellous plugin if I can help it…!
Thanks very much.
ian.
]]>Hey Mikko
I have this snippet in my functions.php. Is it required? What does it do?
Theme tt4, WP 6.6
//Relevanssi Ajax - Fix after wp 6.5
add_filter( 'relevanssi_live_search_add_result_div', '__return_false' );
]]>
Hi there,
We’ve used your plugin for multiple projects and have used the premium version multiple times as well. I’m trying to install the free version on a client’s site to prove that it works better than the native WP search and possibly upgrade to the premium version later. However, the free version is not returning any results when the plugin is activated. I used Query Monitor to grab the search query, and this is what it shows:
SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title * 5 + relevanssi.content * 1 + relevanssi.comment * 0.75 + relevanssi.tag * 1 + relevanssi.link * 0 + relevanssi.author + relevanssi.category * 1 + relevanssi.excerpt + relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf FROM rmb_relevanssi AS relevanssi WHERE (relevanssi.term LIKE ‘ladder%’ OR relevanssi.term_reverse LIKE CONCAT(REVERSE(‘ladder’), ‘%’)) AND ( relevanssi.doc IN ( SELECT DISTINCT(posts.ID) FROM rmb_posts AS posts WHERE posts.post_type IN (‘wps_products’, ‘wps_collections’) ) ) ORDER BY tf DESC LIMIT 500
I’ve bolded the part of the query that is problematic. It appears the results are being limited to these two post types. Those two types are not checked on the “Indexing” tab and there are no references to them on any of the other settings with the Relevanssi plugin. Why are the results limited to these post types? I only want pages and posts in my results. What am I missing?
]]>Hi,
my page is built using Elementor. In the header I’m using the Elementor search widget, however since installing the plugin, the sorting of the search results seems to be unchanged.
For example when I search the word “pizza”, I get posts with the word “pizza” in the post content itself display before others.
Something I realized is that the URL is https://www.lukashaselberger.com/?s=pizza&e_search_props=c51e90d-14031 after searching for “pizza”. When I delete the part of the URL after “s=pizza” and use https://www.lukashaselberger.com/?s=pizza instead, the sorting obviously works correctly.
Can you help me with that issue? Thanks!
Lukas
]]>Issue
I have recently enabled your plugin as well as publishpress revisions pro while using elementor and acf fields. When I try and save a revision on a page built with elementor I was receiving the following error ::
Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array)?must be of type array, string given in?/var/www/html/wp-content/plugins/relevanssi/lib/common.php:1374
That line is part of the relevanssi_filter_custom_fields function. The issue does not occur if I am not creating a revision.
The site is running on php 8.2
Work Around ::
I was able to work around the issue by setting the Custom fields indexing option to visible within the Relevanssi settings admin.
Seems like a bit of an edge case but I figured I would drop you a note about it.
Here is the stack trace ::
I’ve installed the plugin and indexed the site using default settings. The state of the index looks like this:
33 documents in the index.
80 terms in the index.
74 is the lowest post ID indexed.
The site is all pages – no posts
It’s clear from this, from searches and from looking that the relivanessi entry in the database that only the page titles are being indexed. Do I have an issue or is this what is supposed to happen? I’m looking for a search facility that will index all of my pages content so that people can search for specific phrases that appear in the content of pages and not necessarily in the titles?
Hi Mikko
I messing around with the spinner, cause it’s not the coolest I have seen…. So I came across some snippets that should deactivate styles of your spinner. More specifically:
Position Results
add_filter( 'relevanssi_live_search_base_styles', '__return_false' );
and then this that is totally unclear to me:
add_action(
'wp_enqueueu_scripts',
function() {
wp_dequeue_style( 'relevanssi-live-search' );
},
99
);
I tried adding the latter only to functions.php but I see no change….
I am trying to go here…. the Html Structure where loader is the class:
<span class="loader"></span>
And the css goes like so:
.loader {
transform: rotateZ(45deg);
perspective: 1000px;
border-radius: 50%;
width: 48px;
height: 48px;
color: #fff;
}
.loader:before,
.loader:after {
content: '';
display: block;
position: absolute;
top: 0;
left: 0;
width: inherit;
height: inherit;
border-radius: 50%;
transform: rotateX(70deg);
animation: 1s spin linear infinite;
}
.loader:after {
color: #FF3D00;
transform: rotateY(70deg);
animation-delay: .4s;
}
@keyframes rotate {
0% {
transform: translate(-50%, -50%) rotateZ(0deg);
}
100% {
transform: translate(-50%, -50%) rotateZ(360deg);
}
}
@keyframes rotateccw {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(-360deg);
}
}
@keyframes spin {
0%,
100% {
box-shadow: .2em 0px 0 0px currentcolor;
}
12% {
box-shadow: .2em .2em 0 0 currentcolor;
}
25% {
box-shadow: 0 .2em 0 0px currentcolor;
}
37% {
box-shadow: -.2em .2em 0 0 currentcolor;
}
50% {
box-shadow: -.2em 0 0 0 currentcolor;
}
62% {
box-shadow: -.2em -.2em 0 0 currentcolor;
}
75% {
box-shadow: 0px -.2em 0 0 currentcolor;
}
87% {
box-shadow: .2em -.2em 0 0 currentcolor;
}
}
I tried replacing “.loader” with “.rlv-has-spinner” and then I see a freaky combination of the two where your spinner is still dominating the show. So how can I achieve this?
On my site in main menu > search, I trigger SearchWP Modal. And there the java thing trigger when searching. You are welcome to give it a try. “Art” or “Artist” will yield a number of hits. I hope this is possible.
Thx
]]>Hi,
We are currently using Relevanssi on our site and have a specific use case that we are looking to implement. Specifically, we would like to include a certain post type in search results on desktop, but exclude that same post type when the search is performed on mobile devices.
We understand that Relevanssi allows us to include or exclude post types globally, but we haven’t found a way to apply these settings based on the user’s device type (desktop vs. mobile).
Would you have any recommendations or insights on how best to implement this functionality? We are open to using custom code if necessary and are exploring efficient approaches to modify the search query based on the detected device.
Any guidance would be appreciated!
]]>I am getting this error when saving a page on a site that I’m working on.
I have narrowed it down I think to an ACF field on the page. What has me stumped is that I’m not getting the same error on any other pages with the same field.
I have tried deleting all of the content on the page to eliminate special characters causing an issue, no luck.
The ACF field group has two elements. First is a simple true/false switch that when true exposes a text field. Both fields are set with “‘relevanssi_exclude’ => 1”. If the true/false switch is false then the page will save with no issue.
Again, this is a single page of many where I’m getting this error.
Thank youl,
]]>Hi, I am trying to use Relevanssi search in a parent post type view created by Toolset. The search should search data in custom fields of a parent post as well as a child a post. The child post type has a nested view in the parent post type view.
Below you can see a custom code solution to do a search in parent and child post and merge results together but it doesn’t work. Apparently, there should be another way to hook in the post__in argument. Would you be kind to take a look and advice?
function func_rlv_adjust_search( $query ) {
? if(isset($_GET['wpv_post_search']) and $_GET['wpv_post_search']!='') {
? ? remove_filter( 'relevanssi_modify_wp_query', 'func_rlv_adjust_search' );
? ?$args ?= array(
? ? 's' ? ? ? ? ? => $_GET['wpv_post_search'],
? ? 'post_types' ?=> array('parent'),
? ? 'fields' => 'ids',
? ? 'relevanssi' ?=> true,
? );
$parent_query = new WP_Query( $args );
? $args ?= array(
? ? 's' ? ? ? ? ? => $_GET['wpv_post_search'],
? ? 'post_types' ?=> array('child'),
? ? 'fields' => 'ids',
? ? 'relevanssi' ?=> true,
? );
$child_query = new WP_Query( $args );
? $child_posts = array();
? foreach($child_query->posts as $k=>$v):
? ? ?$child_posts[] = toolset_get_related_post($v,'parent-to-child');
? endforeach;
? $final_res = array_merge($parent_query->posts,$child_posts);
? ?$query->query_vars['post__in'] = ?join(",",$final_res);
? // relevanssi_do_query( $query );
? add_filter( 'relevanssi_modify_wp_query', 'func_rlv_adjust_search' );
? ? ?$query->query_vars['post__in'] = ?join(",",$final_res);
? ? $query->set('post__in',join(",",$final_res));
}
// ?return $query;
}
//add_filter( 'relevanssi_results', 'rlv_rating_weights');
function rlv_rating_weights( $results ) {
? remove_filter( 'relevanssi_results', 'rlv_rating_weights');
? ?$child_childs = do_shortcode('[wpv-view name="get-related-child-posts" cached="off"]');
? ?$child_childs = explode(",",trim( $child_childs));
? ?$final = array_merge($results,$child_childs);
? $final_results = array();
? foreach($final as $k=>$v):
? ? $final_results[$v] = 1;
? endforeach;
? //add_filter('relevanssi_results', 'rlv_rating_weights');
? return $final_results;
}
]]>
Hi,
i’m using Elementor to edit my content on my website. But in some specific pages I load custom model to display recurring datas.
I need the content displayed in these pages indexed as well (in fact i need to index content as it’s displayed on front).I tried to replace the content indexed with the content displayed by Elementor.
add_filter('relevanssi_content_to_index', 'clean_elementor_content_for_relevanssi', 10, 2);
function clean_elementor_content_for_relevanssi($content, $post)
{
// Check if Elementor is active and the post is built with Elementor
if (did_action('elementor/loaded') && \Elementor\Plugin::$instance->documents->get($post->ID)->is_built_with_elementor()) {
// Get the fully rendered Elementor content
**BUG if I return dummy data there it's working (even when i return the $cleaned_content text when I log it **
$elementor_content = \Elementor\Plugin::$instance->frontend->get_builder_content($post->ID, true);
**BUG if i return dummy data there it's NOT (nothing indexed for the post when using debugging tool) working **
// Clean the content by extracting only the visible text
$cleaned_content = extract_visible_text($elementor_content);
// Return the cleaned content for Relevanssi to index
return $cleaned_content;
}
// If not built with Elementor, return the original content
return $content;
}
Do you have an idea what’s going on ?
]]>Hello,
I am currently using the Relevanssi plugin on my WordPress website alongside WooCommerce. I’ve encountered an issue specifically with the product search functionality. When I search for a product, the standard WooCommerce ordering options (such as “Order by Price” and “Order by Date”) do not work properly. The results are not ordered as expected. However, I’ve noticed that the shop pages (without using the search) work perfectly fine, and the sorting options there function as intended.
I would also like to mention that I am overriding the woocommerce_get_catalog
hook , which may be affecting the ordering results.
Hi!
I’m trying to build a searchable database for a hospital library, and I’ve encountered an issue with how categories and tags are being applied in the search results.
Here’s the situation:
?s=test&cat=6,46&tag=fakta
, I am expecting the results to only show posts that match either category 6 or 46, while also having the “fakta” tag.I would like to ensure that when a search is performed:
If this behavior isn’t default, could you guide me on how to configure Relevanssi to achieve this filtering logic?
]]>Currently using the free version and after trying many other search plugins that are always recommended on the Lists of Best Search Plugins, Relevanssi so far is the best for the site’s needs.
Except one issue that the other plugins don’t have: on the search results page, the theme has an AJAX powered load more button to show more results. With Relevanssi, that process hangs and does not load more. Sometimes it will eventually load more after several minutes. All of the other non-search related load more instances on the site are working as they should.
Is there anything in Relevanssi that can cause a conflict with a theme’s current load more implementation? Any AJAX conflicts that should be looked into?
PHP 8.1, Lightspeed enabled server with Lightspeed cache plugin.
]]>I have SEOPress and Relevanssi installed, but on the Indexing tab under “Show advanced settings” I’m not seeing the checkbox to exclude noindex
posts from the index.
If I enable other SEO plugins like Yoast or Rank Math, the checkbox shows up. And I can see in /compatibility/seopress.php that SEOPress is supported, and I see the checkbox in that code. So SEOPress must have changed something you were relying on to activate the checkbox?
Hello,
I have been through the help and documentation and still have a problem : the search in the admin dashboard (Admin search) gives the expected results but the front end doesn’t (like : no result, not all the results, …).
What am I doing wrong?
Thanks in advance
]]>Hello Team,
We are currently using the Relevanssi (Version 4.23.1) plugin integrated with FacetWP and the FacetWP – Relevanssi add-on. However, we are encountering an issue where exact match searches are not appearing in the first position.
For example, when searching for the full recipe keyword “easy tzatziki,” the correct recipe appears in the search results but in positions 3-4 instead of being listed first.
We have a custom post type for recipes, and “easy tzatziki” is set as the recipe title. The FacetWP search filter is configured to display these results.
Initially, this issue seemed resolved after deactivating the plugin, clearing the cache, and reindexing in Relevanssi. However, despite repeating these steps, the exact match is still not showing in the top position.
We also tried implementing the following hook as per the Relevanssi documentation to boost exact title matches, but it hasn’t worked:
Screenshots:
Could you please advise on how to ensure that the exact match appears in the first position?
Thank you, and please let us know if you need further information.
Thanks
]]>when I search for e.g. ‘bus’, i get a bunch of relevant results, but towards the end i get results that appear to include search breadcrumbs.
e.g. last entry on page 1:
About us
Home ? Results for bus
About us Our History Our masterplan Citipointe Campus Our History? Born out of the faith and hope of the Christian Outreach Centre (COC), the…
The results on page 2 all have this as well.
Love to hear your thought on why this is displaying this.
]]>Hello
I have created code to sort products by price, but now I am having a problem. When searching for results and selecting sort by price, the result is Variations with only one product price listed first, followed by Variations with more than one product price.
But the result I want is these two Variations. Must be sorted according to the sort by price selected.
Therefore would like to ask for help from the team.
I have attached the code at the end of this message.
Thank You.
// Function to retrieve the price range of variations
function get_variation_price_range($product) {
if ($product->is_type('variable')) {
$variation_prices = $product->get_variation_prices(true);
$min_price = !empty($variation_prices['price_min']) ? $variation_prices['price_min'] : 0;
$max_price = !empty($variation_prices['price_max']) ? $variation_prices['price_max'] : 0;
return [
'min' => $min_price,
'max' => $max_price
];
}
return false;
}
// Function to customize the display of the price for products with multiple variations
add_filter('woocommerce_get_price_html', 'custom_price_html_variation_range', 100, 2);
function custom_price_html_variation_range($price, $product) {
if ($product->is_type('variable')) {
// Retrieve prices of all variations
$variation_prices = $product->get_variation_prices(true);
// Get the minimum and maximum prices
$min_price = min($variation_prices['price']);
$max_price = max($variation_prices['price']);
// Check the price values
if ($min_price > 0 && $max_price > 0) {
// Check if the URL has orderby=price-desc
if (isset($_GET['orderby']) && $_GET['orderby'] === 'price-desc') {
// Display the maximum price first, followed by the minimum price
$price = '?' . number_format($max_price, 2) . ' – ?' . number_format($min_price, 2);
} else {
// Display the minimum price first, followed by the maximum price
$price = '?' . number_format($min_price, 2) . ' – ?' . number_format($max_price, 2);
}
} else {
// If the price is 0, show a message indicating no price is available
$price = 'No price available';
}
}
return $price;
}
// Function to sort search results by price using Relevanssi
add_filter('posts_orderby', 'custom_relevanssi_orderby', 10, 2);
function custom_relevanssi_orderby($orderby, $query) {
if ($query->is_search() && $query->get('post_type') === 'product') {
if (isset($_GET['orderby'])) {
if ($_GET['orderby'] === 'price') {
global $wpdb;
$orderby = "meta_value + 0 ASC"; // Change to DESC to sort from highest to lowest
$query->set('meta_key', '_price');
}
}
}
return $orderby;
}
// Function to sort search results by product price
add_action('pre_get_posts', 'sort_relevanssi_results_by_price');
function sort_relevanssi_results_by_price($query) {
if ($query->is_search() && !is_admin() && $query->get('post_type') === 'product') {
// Check if orderby=price-desc or price to apply the selected sorting
if (isset($_GET['orderby']) && $_GET['orderby'] === 'price-desc') {
// Clear taxonomy filters like categories, tags, and attributes
$query->set('tax_query', array());
$query->set('meta_query', array());
// Sort by price from highest to lowest
$query->set('meta_key', '_price');
$query->set('orderby', 'meta_value_num');
$query->set('order', 'DESC');
} elseif (isset($_GET['orderby']) && $_GET['orderby'] === 'price') {
// Sort by price from lowest to highest
$query->set('tax_query', array());
$query->set('meta_query', array());
// Sort by price from lowest to highest
$query->set('meta_key', '_price');
$query->set('orderby', 'meta_value_num');
$query->set('order', 'ASC');
}
}
}
]]>
Hello someone found an XSS maybe linked to your software. (and maybe link to oxygen
builder too not sure…)
Try to add that at the send of the url :