Posted on

Most important Relevanssi debugging trick

When you have problems with Relevanssi, these are the first steps to take:

  1. Make sure you have the latest version of Relevanssi. If not, upgrade.
  2. Try deactivating the plugin and reactivating it.
  3. Are you using Yoast Local SEO? Read this.
  4. Try deleting the plugin and reinstalling it from scratch.

If that doesn’t help, then approximately 90% of the time the problem is the same: there’s a query_posts() call on the search results page.

Any calls to query_posts() on search results template make Relevanssi fail silently. You’re not getting results from Relevanssi any more. This is unpleasant, but something I can’t really fix, considering that WordPress doesn’t offer any official way to replace search results and the way Relevanssi is coupled with WordPress is something of a hack. So, something simple like this can throw Relevanssi off.

If you’re having problems with Relevanssi, the first step is to check your search results page, usually search.php. See if there’s a call to query_posts() and if there is, comment it out. In most cases that is enough to fix the problem.

It’s not always query_posts(). Appearance of new WP_Query() is another sign of trouble, or $wp_query->get_posts();. Anything that queries the database for new posts is trouble for Relevanssi.

If you need help, you can post on the Relevanssi support forum. Please include the contents of your search results template, put it in a pastebin and share the link.

227 comments Most important Relevanssi debugging trick

  1. Hi, I got into some problems with the Twenty Eleven theme, when I activate Relevanssi I cannot read much in the search result page. In fact it crashes in a strange way.

    There is no such call to query_posts, of course. More tips for troubleshooting would be welcome…

    1. My mistake. I was messing up with searchblogs in a wrong way (empty value). Maybe is a good idea to sanitize this value if empty…

  2. Mikko, I notice you’ve been furiously updating Relevanssi Premium. Still, if I put admin in the exclusion box, admin searches are all that’s logged. With nothing in the box, it logs all searchers, including of course admin.

    1. Oh, sorry. I’ve forgot about that… I’ll add it to my new bug tracking list right away, and I’ll be sure to check it out the next time I’m working at the plugin.

  3. Hi Mikko– you’re working hard on updates. Here’s the status of my problem: I login as wpadmin. If I exclude that (or even wp) from the search, it logs my searches, yet no other users’.

    I excluded only “juju” and it logged both my searches and others’. So exclusion works with non-administrative entries.

    I hope this can be solved. Thanks, Philip

    1. Hi Mikko– I have tried all combinations of user id and password…using id first as name and then as password. No combination works. I don’t think I have registered before, so I clicked register. That always brought me back to this page…no place to register.

      And search exclusion of administrator doesn’t work…even with your latest update.

      Help! Philip

  4. Yes. I excluded my user id and it logged both admin and all other searches. I even tried excluding just the numeric part of my id with the same results.

  5. Fuzzy matching not working. I only want to search ‘whole’ words. Why is it so difficult to find a plugin or hack to do that? I don’t want anything else, only whole words.

    1. Disable fuzzy matching, and Relevanssi will match only whole words. It’s simple as that. If you use highlighting, that may be a bit deceptive, as the highlighting will highlight partial words – that’s not what Relevanssi matches, it’s just the highlighting.

  6. I’m using a MySiteMyWay theme and they have a whole framework it’s built on so finding the query_posts() call is really hard (it’s in lib/functions/theme.php, line 1449 for me, but I don’t want to make framework changes). So I added a wp_reset_query(); call in search.php. It now looks like:


    No idea whether this is going to cause cancer or have other side-effects, but it worked out well for me!

  7. For some reason, searches stopped returning results. It had been working fine, now nothing. Even rebuilding the index doesn’t work. No query_posts(). Any suggestions for debugging? The log shows lots of successful searches in the past, but now nothing.

  8. PS — The index appears to be good:

    State of the Index

    Documents in the index: 2049
    Terms in the index: 89133
    Highest post ID indexed: 13352

    Just nothing on search results page.

  9. I get the same issue as Bob. Lately I updated WP to 3.4.1 and twenty ten to 1.4 (I am using a child theme of twenty ten).

      1. I’d love to hear how Bob’s issue gets resolved as well, since I’m seeing the same thing. It used to work a few weeks ago, yet now it doesn’t provide any results.

        If I disable the plugin and search the same terms, it provides tons of results.
        Re-enabling and re-indexing doesn’t change the no results issue.

        I also made sure there was no query_posts in the search.php document.

          1. I’m running Relevanssi 3.0.3 for the fist time on WP 3.3.2 and I’m getting the “No posts yet !” message. Index built successfully.

            I’ve commented out the query_posts in my search.php.
            I’ve deactivated and reactivated several times.

            Still no search results. Do you remember how you helped Bob?

  10. I have an issue with the title boost and no query_posts() call on my page. The titles of my posts, pages and custom post types doesn’t seem to get the needed relevance, even if I have set the boost to 5 in the Relevanssi-backend. I want the search results that way, that if the title matches, the post/page is on top of the results. How to do that?

  11. Hi – I’m using WordPress 3.4.1 and Relevanessi Version 3.0.1. I think I’ve used the plugin for over a year or two with no problems. Now, some time reasonably recently (last few weeks?) it’s stopped working (just get a “no results” message when searching). I’ve double-checked for the presence of query_posts() but it’s not there. I notice a couple of other people here have what might be the same problem.

  12. Hi, ever since the 3.0.2 upgrade my search results have odd code at the end. It’s probably because I’m also using the GD Star Rating plugin. But the previous version of Relevanssi didn’t do this. Here’s a sample:

    This is Victoria just west of Beacon Hill Park from 1954. You can still make out the Empress Hotel and the Parliament Buildings off in the distance. UA:F [1.9.20_1166]please wait…Rating: 0.0/5 (0 votes cast)…

  13. Hi,
    Can you please let me know what needs to be done to make the plugin working with optimizepress? It is not showing any search results after indexing pages

    Thanks much,

  14. Hi Mikko,

    I really like your plugin. There is one thing I can’t seem to fix:
    I want to show custom excerpts of “pages” including a custom read more link.

    Framework:
    Roots: http://www.rootstheme.com/

    For enabling page excerpts I used:
    http://wordpress.mfields.org/2010/excerpts-for-pages-in-wordpress-3-0/

    For enabling custom read more links I used:
    http://codex.wordpress.org/Function_Reference/the_excerpt

    code used:
    function new_excerpt_more($more) {
    global $post;
    return ‘ID) . ‘”>Read the Rest…‘;
    }
    add_filter(‘excerpt_more’, ‘new_excerpt_more’);

    In the plugin:
    – Create custom search result snippets: enabled
    – Allowable tags in excerpts: -blanc-

    Somehow I’m not seeing it and I’ve maxed out my daily coffee intake so if you are able to help me fix it or point me in the right direction that would be awesome.

    oh and no query post shizzle going on.

    Regards,
    Toni

    1. Yeah, looks like the excerpt_more filter doesn’t work. Here’s a workaround I found in Twenty Ten:

      function custom_excerpt_more( $output ) {
      	if ( has_excerpt() && ! is_attachment() ) {
      		$output .= " > Read the test";
      	}
      	return $output;
      }
      add_filter( 'get_the_excerpt', 'custom_excerpt_more' );
  15. The test is read.

    First part works!
    Thanks for the quick reply
    Up to styling now.

    One point:
    It still displays the first few lines of the page instead of the custom excerpt.
    How do I hook into my custom Excerpt? Or is the above code for enabling excerpts on pages not accurate anymore?

    Regards,

  16. If your theme is using the_excerpt() on search results pages, Relevanssi should take over the excerpt, and it doesn’t matter if you have the excerpts enabled for pages or not.

  17. Mikko,

    It appears for us (using HTML5 Reset Framework), we are seeing the index build, but we are not getting results for custom content types (using Custom Content Type Manager) and custom fields (specifically relation type fields).

    Some of the content is found in the index table but does not show as a result. We should note that the terms are being picked up and indexed for the entire custom post type, just not found as a result.

    Is there a way we can extend the indexing or results to show this?

    Thanks!

    1. Bill, if you’re a registered user, please use the support form to send me more details. Which version are you using? What are those content types? Are they post types, or something else?

  18. Hi Mikko,

    I love Relevanssi and thank you for all the hard work. I’ve got a problem that I’ve just noticed recently, one that persists even if I turn off Relevanssi, but I’m still hoping you might be able to help me zero in on the fix:

    Some search results to pages and posts are suddenly missing links to the source. For example, look at this page: http://www.aur.edu/american-university-rome/?s=accu&submit=Search

    Notice the first two results don’t have links, but the third that includes the h2 title does and the next one with the h2 title and featured image does.

    Any idea as to why this is happening?

    Yes, I have checked my “search.php” for query_post call and I’m clean. Any and all insight you can provide would be greatly appreciated.

    Cheers,

    Tim

    1. Tim, problem is in your style sheet. All those results have h2 titles, but your style sheet sets .page-title to “display: none”, which means they don’t show up. The post meta and bylines appear on those two results, because those two are posts and the other are pages. The answer to that problem lies in your search results template.

        1. Took a look at your site using the “Inspect element” feature of Google Chrome. It’s the best tool for a web designer. For Firefox, you can use Firebug, and other browsers have similar features.

          1. Fixed!!! I changed the CSS to h1.page-title to display none… and now the h2’s appear in the search.

            Yes, I use the equivalent tool in Safari, but I overlooked what you clearly saw.

            Thank you again so very much, Mikko!

            Cheers,

            Tim

  19. Hi Mikko – I installed your plug-in and then get no results. There does not appear to be a query_post() call in the search php. I must be doing something wrong but I cannot figure it out. Your plug-in is disabled on the site right now. Thanks for any help you can give.

  20. Here’s what I have – any help would be forever appreciated!

    News Topics

    <div >
    <h3 id="post-“><a href="” rel=”bookmark” title=”Permanent Link to “>

    <?php the_tags('Tags: ', ', ', '’); ?>
    Posted in

    |

    No posts found. Try a different search?

  21. Hi there. I’d like to first say, great plugin! It’s made our search a lot more useful, and is very simple to use.

    I am having one problem-whenever the search string is wrapped in quotes (e.g., “foo bar”) the page dies, but wordpress doesn’t throw any fatal errors. I am using query_posts() (but in the sidebar, not the search result section), but commenting them out didn’t help.

    Any ideas?

  22. Hello, I installed this plug-in and set the right settings. But I’m stuck now. How do I add the searchoption so this is visible on a page or in the widgetarea? my site is in dutch

    If it works good im getting the premium version.

  23. New WEB site soon to be launched. I must say that this is by far the best search engine for sites that I have ever seen. But, I have a small problem. Our site is all about “Wi-Fi” so people will search for this term. Problem is that relevanssi interpret this as a Boolean NOT searching for all pages containing Wi but not Fi, no pages will be found in searches…….
    I there any way to:

    A. Have a “include” word saying boolean NOT should not be used for th term Wi-Fi.

    OR

    B. Disable the boolean NOT feature

    A bonus question:

    People may use wifi, WiFi, Wi-Fi when searching, but my site use Wi-Fi, is there any way to define alternative words that should be tied to the indexed Wi-Fi term? So searching for wifi will include results containg Wi-Fi?

    Thanks in advance!

    1. First of all, if you’re running the free version of Relevanssi (I assume so, as you’re not using the customer support form to contact me), there simply isn’t a boolean NOT operator in Relevanssi.

      What you’re seeing is punctuation removal, which replaces the dash with a space, resulting in “wi fi”, which is then not searched, as the minimum word length for indexing is 3 by default.

      Relevanssi is case insensitive, so that doesn’t matter. There’s the synonym feature which you can use to support alternative spellings, but what I suggest here is a simple function:

      add_filter(‘relevanssi_remove_punctuation’, ‘fix_wifi’, 9);
      function fix_wifi($str) {
      $str = str_replace(‘wi-fi’, ‘wifi’, strtolower($str));
      return $str;
      }

      After you add this to functions.php of your theme, reindex. Now every occasion of wi-fi, in posts and search queries, will be normalized to wifi. Problem solved.

        1. Hey Mikko,

          i’ve a similiar Problem and could not get any result while looking for “R.O.O.M”, what is a post_title.

          I tried setting ‘relevanssi_min_word_length’ to 1, but it doesn’t work.
          Then I tried to use your synomys feature and defined ‘room = R.O.O.M.’, ‘ROOM = R.O.O.M.’ and it also returned zero results.

          My last try was using your “fix_wifi” filter function from the comment above. I modified it to str_replace(‘r.o.o.m.’, ‘room’, strtolower($str)) but at all nothing worked.

          I hope you could point me into the right drection.

          Regards Carsten

  24. We have a strange problem with Relevanssi. We made the index without problems, but on the site we have no results, but we can see hits in the Relevanssi User Searches. The admin searches works fine,, but no results on the side.
    So far as well. We have a Developer Environment, where we use exactly the same Software and there it works fine. We make a svn checkout on our productivity server, so it is exactly the same software, but it does not work outside.
    I changed the theme outside but i got no results. I interchange the DB, but it only work in the developer Environment.
    So we supposed that it is a spooky php fenomen. But there is nothing in the error.log
    Perhaps you have any suggestion?

    1. Dirk, last time someone had a problem like this, it was caused by a subtle difference in either Apache or PHP configuration between the development and production environments.

          1. OK, I Found the source of defect. It was a different Theme of WPTouch Pro, which is a Plugin for Mobile Devices. I could not imagine that this has influence also to the Webtheme, but it could.

          2. We are having the same problem with Relevanssi not working with WPTouch Pro – not showing results
            using any theme that came with it – how did you solve this problem?

          3. The Classic-Theme work for us and I could make a Childtheme from that as well. Do you make any Searchmanipulation in the root-functions.php?

          4. we made no modifications to search and none to the themes and none to the plugin code. What weird is that it shows that there are a number of results, but the actual page says no results found, directly below where it says the search returned x number of results. So I’ll do a search and get a page where at the top it says I have 29 results in the header area, and below that the search results page itself says there were no items in my search. you can see this at http://www.ablogtowatch(dot)com on the smartphone

          5. This is not the same Problem I had. My Search did not work for both: Mobile and Desktop. I had made Category Exclusion for the Search in the Mobiletheme and for that relevansi did not work. But I was surprised that the Mobiletheme from WPTouch Pro effect also my Desktoptheme (Thematic).

            Your Desktop search works. So I think you have to modify the root-funktons.php to add the search result. Does your Mobile search work without relevansi?

          6. mobile search does work without relevanssi – I think I have to find another solution because we need mobile to work

          7. Probably 3 years too late, but the reason is that search.php in the WPtouch theme uses a custom query. Instead you can use the code from index.php as a base which just loops through the default query.

  25. Im having a similar issue. It worked when i downloaded and tested it but just recently i see no results on the search page, only hits in the user search logs. I tried everything above, and an upgrade of the plugin but still no results show.

      1. I can exactly remember the original version, i think 3.0.1 i have since upgraed to Version 3.1.3. Both versions were not displaying results. wordpress version 3.4 I understand you can only guess at this point, so any pointers or PHP settings you know of would be great, thanks!

        1. I’d start by looking at a var_dump($wp_query); on the search results page to see if there’s anything unusual there, then I would drop var_dump() calls in Relevanssi search functions (relevanssi_search() in lib/search.php) to see where in the process the results go missing.

          Actually, start in relevanssi_query() (also in lib/search.php) – does it return the search results in $posts variable or not?

          1. when i ran var_dump($wp_query); on the search results page it returned nothing, but when i do var_dump($wp_query); inside the relevanssi_query() function it returns matching results in an the array. so it is finding the results just not displaying theme, could be a theme issue i guess based on that.

          2. Some online shop site I fixed – I’m not sure if it was WP-eCommerce or some other plugin – had a search form that by default excluded products from the search.

            Add this to your search results page: global $wp_query; var_dump($wp_query->query_vars[‘post_type’]);

          3. global $wp_query; var_dump($wp_query->query_vars[‘post_type’]);

            returned blank… im pretty stumped on this as i have not updated anything or even installed new plugins that would cause this conflict.

          4. It would help a lot if I could take a look at your site. But check your search form or eCommerce plugin settings to see if the search is not excluding post types.

          5. Mikko,

            I appreciate your support, especially since it was free and you did it in your spare time. However i have since purchased a plugin specifically for wp-ecommerce product search. Thanks again!

  26. I get no results from relevanssi after I upgraded to the latest version. even when I disable the plugin I get no results in the search page. Anything I should be checking? I’m using this plugin with jigoshop to search products. the post type is “product” and I checked it in the settings page to be indexed.

  27. Hi,
    first of all I’m a foodblogger from Germany and not a developper. I was using Relenavanssi succesfully during the past month but now I get an “error 404 page not found” after entering a search criteria. How can a dummie like solve that problem?
    I’m using 3.1.3.
    thanks so much.
    Claudia

          1. You copied the code incorrectly. Make sure the code looks exactly like I posted it. It doesn’t, right now. Do not use copy-paste, but write it yourself. Make it look exactly like in my example.

          2. thank you so much for your kind support. I did not copy the code – I typed it. Still it does not return any results. It says that possibly the page has moved. Could it be that somewhere in the function bloginfo(‘url’) there is an invalid path? could it be that I have to change it somewhere on the DB? or in one of the files?

          3. No, the code is wrong. I can’t write the code here, because the comment form mangles it, but it starts (ampersand)lt;?php when it should have (less-than-sign)?php. In the end there’s (ampersand)gt; where a greater-than sign should be. If you’ve written less-than signs and greater-than signs instead of the codes, then you’re using an editor that cannot be used to modify HTML code, and you need an editor that doesn’t ruin PHP code.

        1. 51584012240167772151

          9
          6
          1036
          93

          FontSize=10000;FName=Arial;Kursiv=0;ULine=0;SThru=0;ForeColor=0;BackC=16777215;TextColor=0;Align=0;BW=1;BS=0;BA=2;BST=2;NOPRINT=0;ArrowType=0;UIDEFMODE=0;;IsLinkValue=0;UseUnique=-1;NLines=1;NChars=30;;;

          *DBField
          7
          2864
          000000000VICT_DBA14F102C13E41B8F

          that is what I copied from the search form

  28. WP 3.5.1, 18 posts, 48 pages
    First ever Relevanssi install, all settings default
    I have indexed
    I looked through search.php and loop.php and did not find query_posts()

    Problem:
    Page title ‘About Us’ with permalink /about cannot be found by searching ‘about’, ‘about us’, etc.

    Possible issue:
    The server is IIS7, with .htaccess fix for permalinks. – yeah, it’s bad but I can’t change it

    Thoughts?

    1. “About” might be a stopword. Check the stopword list. I don’t think it’s a huge problem – who searches for “about us” page of a site, with those words? I don’t think many people do.

      1. It’s not too big a site so removing the stopwords ‘about’ and ‘us’ shouldn’t be a problem. And, so far, it looks like we’re in great shape. You have another follower, thanks!

  29. Hello,
    I´ve running relevanssi for last 4-6 months.
    Everything seems to be OK. Plugin was updated two-three times without any problem.
    But I´ve just updated to version 3.14 and Relevanssi doesn´t work: when searching nothing is found.
    I´ve rebuild the index and deactivate-activate the plugin but problem remains.
    When deactivating elevanssi standard WP search works OK.

    I´m running WP 3.5.1

    Any suggestion how to fix the problem?

    Thanks!

    1. At least those codes have nothing unusual. ar2_above_content() might have something in it, but I’m not sure. And you’ve tried deactivating and reactivating the plugin and reindexing the content? Indexing works well?

  30. Hi,

    there are no documents in the index.

    $wpdb->print_error(); Shows no error. So I debugged a query and tried to execute in in phpMyAdmin. The result was an error:

    #1136 – Column count doesn’t match value count at row 1

    Can I post (the very long) query here?

    BTW: We use a Multisite Installation.

    Cheers,
    Lars

      1. Well, that’s strange. I came here looking for help with a problem similar to the original poster: ie. Relevanssi works great on my development laptop but doesn’t seem to be able to build the index on my live server. Both WP setups are the same, as I use git to sync changes between the dev and production servers.

        The thing is, I’m using WP multi-site and Relevanssi most definitely *does* work –at least on my development machine. Unfortunately just not on the production server.

  31. Hi. My Theme company (ElegantThemes.com) specifically recommended Relevanssi to use with their theme, “Origin.” They recommended Relevanssi to me because the standard WP search only returned search results from “posts” (but not “pages”).

    I am not seeing any different behavior from Relevanssi, so I think it’s not working at all. I looked for “query_posts()” within my search result page (search.php), but found none. However, I am not a developer, so perhaps I am not looking correctly.

    Here is the source for search.php. Do you see anything I should change?

    Gratefully,

    -Matt

    =================================

    <a href="”>

    <?php if ( $thumb ” && !$et_ptemplate_showthumb ) { ?>

    <a href="”>

    <a href="” class=”readmore”>

    1. Hmmm. my full page is not showing here, but when I click “edit” it shows… Can you see it? Or should I email it to you?

      1. If both Relevanssi and default WP search are returning only posts and not pages, you have the post_type set to ‘post’ somewhere. Since your theme designer recommends Relevanssi as a solution, I suppose it’s not in the theme.

        The best way to share template pages is to put them in a pastebin. You generally can’t copy and paste HTML and PHP code to comment forms and have it stay intact.

        If you buy a Premium license, I’ll be glad to see how to get things working on your site; unfortunately there are limits to how much I can help people who are not Premium subscribers. If you show me your search results template and functions.php files, I can take a look at them and see if it’s something obvious.

  32. Hello! i have a theme Infocus (themeforest) which seems to be not compartible with free version of Relevanssi as it is… so my question is: if i’ll buy the pro version of relevanssi will that fix the problem? or will i have support to fix that? i tried to find query_posts() in my theme files but i didn’t find anything like this…
    what could be done fore better search results on my web-site (http://freak-cabaret.com/)? thank you!

    1. Switching to Premium won’t change anything: it’s that similar to the free version. If you buy Premium, I can take a look at the theme, but I can’t promise that I can make it work with Relevanssi, and the support doesn’t include complex changes in your theme to make it compatible with Relevanssi.

      Usually the problematic themes are fairly easy to fix, but not always. The more complicated a theme is, the harder it is to fix. If you can send me the search results template from your theme (usually it’s search.php), I can take a look at it and let you know if it looks like an easy job or a difficult one. My email is mikko@relevanssi.seravo.fi.

    1. It’s quite possible the contents of your tabs are invisible to Relevanssi. It all depends on how they’re done. Is it a shortcode? Or something else?

      What comes to doubling of search results, that sounds like a problem with your search results template.

  33. Hi,

    I have installed Relevansii with theme Twenty twelve and it works perfectly.
    But in another installation with plugin WPML and theme Construct a problem appears: Relevansii builds an Index but searches do not provide any results.

    In WP control panel > Relevansii > settings I have enabled Polylang
    On server… / WP content > plugins > Relevansi I renamed the directory to and the file to . Is it correct?

    My theme’s file Search.php is available at if you like take it a look.

    I have no experience as a developer and work for a non-profit organization. Can you help me to solve this problem, please?

        1. Ah, it’s a framework theme. Those are always more complicated to debug, as that template file contains nothing of use – the actual search page template is inside the mysite_search() function. Where that is, I don’t know. I can’t usually do much of a support for framework themes.

          1. Hi, M. this is the framework response ???:
            “We use the query_posts, you can find it in various areas in the
            theme.php file. It’s used for lots of areas in the theme such as
            excluding categories, portfolios, etc etc.

            It would probably be best to try and find another plugin.”

          2. Ok, so this sounds like switching search plugin or theme is the easiest solution here. I suppose Construct and Relevanssi can be made to work together, but it’s not going to be easy, and it’ll require changes to Construct files.

          3. I share your opinion, Mikko.

            I have passed your answer to Construct-framework developer (Mysitemyway) or which suggest me how can I Boolean and advanced search with its product Construct.

            This is his response: “You would need a plugin or hire a custom freelancer to do that customization.”

            Is it really necessary to hire a freelancer? As you know, we have no budget in this organization now =(

          4. Well, unless you find someone to do it for free or do it yourself, then yes, you have to hire a freelancer. I know it’s complicated enough that I can’t do it for you for free.

  34. Hi I just updated to the last version and started getting mysql errors. I am not really sure what version I was but it was a recent one.

    MysqlError: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘) AND ((relevanssi.doc IN (SELECT DISTINCT(posts.ID) FROM wp_posts AS posts W’ at line 2

    Sample stack trace

    …mysql_query called at /var/www/receitasdemae.com.br/html/wp-includes/wp-db.php (1213)
    …wpdb::query called at /var/www/receitasdemae.com.br/html/wp-includes/wp-db.php (1538)
    …var/www/receitasdemae.com.br/html/wp-content/plugins/relevanssi/lib/search.php (515)
    …var/www/receitasdemae.com.br/html/wp-content/plugins/relevanssi/lib/search.php (971)
    …var/www/receitasdemae.com.br/html/wp-content/plugins/relevanssi/lib/search.php (42)
    in relevanssi_query called at ? (?)…

    Index looks ok, I already tried recreating it. Also tried to disable/enable the plugin again.

    1. Is there any chance you could get me the problematic MySQL query in it’s full form?

      For example, try this code:

      add_filter(‘relevanssi_query_filter’, ‘rlv_q_f’);
      function rlv_q_f($q) {
      var_dump($q);
      return $q;
      }

      1. Hi Mikko, I had replied to that days ago and for some reason the reply dissapeared. Maybe because of the SQL in the comment. So I will try to send it with a screenshot. The problem is that there is some ” IN () ” in the middle of it

  35. Hi, your plugin displays my category results fine which i need, however it only displays the posts images and not the full text, I only see ………….
    in the result and no text. Any idea how to fix it , thanks Greg.

    1. Relevanssi doesn’t actually have much to do with what you see on the search results page, that is up to your search results template. Check your search results template.

  36. “Appearance of new WP_Query() is another sign of trouble, or $wp_query->get_posts();. Anything that queries the database for new posts is trouble for Relevanssi.”

    It is not clear by this comment if a theme has this within its code if this is a show-stopper not to use Relvanssi. Please provide what is the resolution if found.

    Thank you

    I am using theme Docs, and it contains:

    function have_posts() {
    global $wp_query;
    return $wp_query->have_posts();
    }

    which is called within docs/index.php:

    query_vars[‘post_type’]); ?>

    ID );
    if ( $post_type == ‘post’) {
    get_template_part(‘templates/post’, ‘loop’);
    } elseif ( $post_type == ‘page’) {
    get_template_part(‘templates/page’, ‘loop’);
    } else {
    get_template_part(‘app/’ . $post_type, ‘loop’);
    }
    ?>

  37. My template uses “WP_Query()”, when I comment it out though it breaks the whole template. Should it be replaced with something else?

  38. Hi,

    We have a custom taxonomy archive which shows no results when the Relevanssi plugin is enabled, without the plugin everything is fine.

    In this taxonomy archive we have a query_posts to change the order of the items.

    How can we make sure Relevanssi only does it’s thing on the search page and not on he taxonomy archive (or any other page)?

    Thx!

    1. This is a WP 4.0 feature. This code in your functions.php should solve the problem:

      add_filter(‘relevanssi_prevent_default_request’, ‘rlv_fix_archive_kill’, 10, 2);
      function rlv_fix_archive_kill($kill, $query) {
      if (empty($query->query_vars[‘s’])) $kill = false;
      return $kill;
      }

      1. Hi Mikko,

        Thanks for your help!

        I’ve added the code to my functions.php and it actually does what it is supposed to do (not replacing the request with “SELECT * FROM $wpdb->posts WHERE 1=2”).
        But the taxonomy archive still displays no results, so I think it must be something after that.

        Any ideas?

        Thanks!

          1. In relevanssi_query() $search_ok is true so $posts gets modified, but even when I edit the function to return $posts as it is there are no results.

            At this point $posts contains the right results.

            Weird thing is that on the taxonomy archive page is_search() returns true after query_posts, before query_posts it returns false.

      2. Mikko, I am running into this same issue, but the page is an ajax call. It doesn’t seem to be firing the filter because it’s on a blank template, due to it being an ajax call. Can you please tell me how to apply this fix for an ajax call?

  39. Hi. I am using implicit theme in WordPress version:4.0 for my website. And when I use these plugin in my theme it does not show any search results.And when I change the theme it works properly and show all results.

    Can any one help me??

          1. 2) {

            foreach($builders as $builder) {

            it_shortcode($builder);

            }

            } else {

            echo do_shortcode(‘[blog title=”Blog” icon=”magazine”]’);

            }

            ?>

          2. Ok, Thanks for your reply.

            But can you suggest me any option through which i can get some clue??

  40. please help how to remove search results query code to fetch the results from this search..please help..this is my search results whole code ..what to remove?

    (found_posts; ?>)

    <a href="”>
    .

    <?php get_footer();

    1. Hassan, please post the complete code to a pastebin, looks like the comment form has eaten part of the code. If that is all the code, then your template is missing several required parts.

    1. Hi, since you’re a Premium member, please use the Premium support service – it usually gets answers faster.

      Anyway, changing the_permalink() on search results template to relevanssi_the_permalink() should do the trick. If this doesn’t work, please reply to the support email address (you can find on the sidebar in the Relevanssi settings page).

  41. Hi,Mikko,help me with this problem.I want my clients to search something in my portfolio posts,that is where I put my product in.It seems like I can just search the words in the tittle!When I search some words in my portfolio posts,nothing appeared!I already set to index portfolio,but still I can’t search words in my portfolio posts but not in the tillte.Can you tell me how to work?

    1. Not with this information. If Relevanssi can’t see the content of posts, it may be because you’re using shortcodes or page builders to create the content. Or is the content perhaps in a custom field?

    1. That video is based on Relevanssi 2.7.2. The vulnerability was fixed in 2.7.3, and Relevanssi has since been checked to make sure that all user input goes through necessary security measures.

  42. This could be a great help resource if you would actually share what code to use besides what’s known not to work.

    1. Ah, but that’s the thing: there is no code necessary. The default search results template (see for example WP default themes) works fine. If you have a problematic code (as mentioned in the post), just remove it, and usually you don’t need to add anything.

      1. That’s true, if you have a default WP install. I had to develop in Timber + Bedrock, it’s a fork, slightly different, search uses. WP_Query in that version. If I remove that, obviously nothing will happen 🙂

        The answer would be:
        https://wordpress.org/plugins/relevanssi/faq/
        “Direct access to query engine”

        I’ll use that, it would be better to add it to a tutorial page.

        1. That is very much beyond any basic tutorials. But since you’re a developer, it’s not that hard to use, really. Create a WP_Query object with the parameters you want and pass it to relevanssi_do_query(). If your WP_Query object is called $query, the results will be in $query->posts afterwards.

          1. Yeah, thanks, I’ve read it in the FAQ, looks simple enough. I’m just suggesting to improve the docs, because it was very confusing for me, I found the FAQ by accident.

            I don’t really know WP works, some code snippet or search.php setup might help people.

      1. Fatal error: Function name must be a string in /home/histor69/public_html/wp-content/themes/multinews-child/search.php on line 181

        That is a if ( $have_posts() ) line….

          1. Your theme has enough modifications in the search results template that making it Relevanssi-compatible will require more work. Unfortunately some themes are like that.

  43. Hi, my search stopped working for some reason… It doesnt show ANY results… but it did few days ago. I’m not aware of any changes.
    https://www.autocadblog.cz/?s=DWG&submit=Search

    I put this line in my search.php: global $wp_query; var_dump($wp_query->query_vars);

    And this is the result, but I’m not clever from that:
    [“author_name”]=> string(0) “” [“feed”]=> string(0) “” [“tb”]=> string(0) “” [“paged”]=> int(0) [“comments_popup”]=> string(0) “” [“meta_key”]=> string(0) “” [“meta_value”]=> string(0) “” [“preview”]=> string(0) “” [“sentence”]=> string(0) “” [“title”]=> string(0) “” [“fields”]=> string(0) “” [“menu_order”]=> string(0) “” [“category__in”]=> array(0) { } [“category__not_in”]=> array(0) { } [“category__and”]=> array(0) { } [“post__in”]=> array(0) { } [“post__not_in”]=> array(7) { [0]=> int(889) [1]=> int(601) [2]=> int(188) [3]=> int(880) [4]=> int(9) [5]=> int(757) [6]=> int(874) } [“post_name__in”]=> array(0) { } [“tag__in”]=> array(0) { } [“tag__not_in”]=> array(0) { } [“tag__and”]=> array(0) { } [“tag_slug__in”]=> array(0) { } [“tag_slug__and”]=> array(0) { } [“post_parent__in”]=> array(0) { } [“post_parent__not_in”]=> array(0) { } [“author__in”]=> array(0) { } [“author__not_in”]=> array(0) { } [“meta_query”]=> string(0) “” [“posts_per_page”]=> int(-1) [“ignore_sticky_posts”]=> bool(false) [“suppress_filters”]=> bool(false) [“cache_results”]=> bool(true) [“update_post_term_cache”]=> bool(true) [“update_post_meta_cache”]=> bool(true) [“post_type”]=> string(3) “any” [“nopaging”]=> bool(true) [“comments_per_page”]=> string(2) “50” [“no_found_rows”]=> bool(false) [“search_terms_count”]=> int(1) [“search_terms”]=> array(1) { [0]=> string(3) “DWG” } [“search_orderby_title”]=> array(1) { [0]=> string(40) “acadblogwp_posts.post_title LIKE ‘%DWG%'” } [“order”]=> string(4) “DESC” }

  44. I’ve installed Relevanssi and built the index, but I cannot figure out how to make a search bar show up on my site anywhere. Any tips?

  45. Hi. I’m sure this is a dumb question but I’m new to this and i don’t see any difference in the search function am i doing something wrong in the code? i just installed the plugin and created the index but the search isn’t any different?

      1. thank you for the really quick reply. I’ve just checked my custom mobile menu its working on that but not in desktop. I’m using Labomba is there any known issues with this theme do you know?

        1. First time I’ve heard of the theme, so I don’t know. Does Relevanssi work with one of the default themes? In that case it’s a theme incompatibility, which most of the time can be fixed with the instructions on this page.

          1. ah right ok. No i cant change my theme because of the one of the links to woocommerce. ill try and redefine the search term for the desktop because i know the mobile menu has a different term to the desktop. once again thank you for the quick reply!

  46. Hi. I try to search for a woocommerce article number (sku).

    The sku ist saved in a format like this: 978-3-3801-1010-3 but can also be shorter for example 971-4-313-334-1. If the user search exactly for this string, the product will be displayed. But often the user searches for the number without the “-“. Then the product will not be displayed. The fuzzy-search is active.

    Do you know any workaround, to display the correct product also if the user searches for the sku without the “-“?

  47. Thank you for your great plugin.

    I have a plugin (User Gallery Lite for Ultimate Member) and would like to use this plugin with Relevanssi plugin but unfortunately Relevanssi plugin can’t find this plugin (User Gallery Lite for Ultimate Member) in Indexing option table and can’t index my images when I upload them to database. Can you please help me to modify your code in order to find the plugin in indexing option table?
    Thanks,
    Alex

    1. Sorry, can’t help you there. If the images are not a custom post type, but instead in a separate database table, Relevanssi has no access to them, and it’s really difficult to fix.

  48. I am so sorry this is elementary, but I do not know how to get the this search functionality on my top navigation bar next to Contact? Any help appreciated. I have installed and activated the plug-in.

  49. Hi,

    I was wondering whether your plugin can index more than 100,000 images? If no, what plugins you suggest for large database?

    Thanks,
    Alex

    1. Can’t really help just based on image; seeing the site and the CSS code would help. But this is not Relevanssi-specific, anybody with CSS skills can help you with this.

  50. Is there a link to adding images to search return? I am trying to differentiate between products and posts, and images would help greatly but I can’t get them to populate. And I can’t find a post about this issue.

  51. Is there a link to adding images to search return? I am trying to differentiate between products and posts, and images would help greatly but I can’t get them to populate. And I can’t find a post about this issue.

    1. The post type is stored in $post->post_type. You can use that to display different images for products and posts.

      There’s no documentation about this here, because it’s not a Relevanssi issue, but instead depends on your theme.

  52. Hi,
    I am having an issue with searches on the front end of our website. When I enter the SKU #, description, name, and/or keywords into the product tags, Relevanssi usually pulls up the product I am looking for, but if I don’t have any tags entered in, it won’t find the product. Usually not even close, either. The back end works just fine, but I can’t pull up the product I’m looking for on the front end of the website. Short of entering tags for every product, I don’t know what to do. Any suggestions?

    1. Are you sure the search is powered by Relevanssi in the first place? If you disable Relevanssi, does that make any difference at all in the search?

      In order for Relevanssi to find products by SKU, you must adjust Relevanssi settings so that the “_sku” custom field is being indexed. Have you done that?

      1. I wasn’t the one to initially set it up, so I’m not sure what was done. I did try disabling it, and re-enabling it, and both did little to nothing. How do you adjust the sku custom field?

        1. Add “_sku” to the list of custom fields to index, rebuild the index. That should do the trick. But disabling Relevanssi should modify the search results, if they are powered by Relevanssi, so if nothing happens, they’re not.

          1. Where would I locate the list of custom fields? Is there any way you can post a screenshot of what you’re talking about? I’m sorry, I am learning about all this as I go. I’m in no way a coding expert. Thanks for your help.

  53. Hi,

    Thanks for the great information and your quick response times. I am using a Theme named “Porto” for my woocommerce shop and I don’t think the search results page is showing Relevanssi results due to some code on the search.php page.

    Fixing that is beyond my skill set and I was wonder, do you have any recommendations to edit search.php or can help me get this going?

Leave a Reply

Your email address will not be published. Required fields are marked *