• Resolved InterlockSolutions

    (@interlocksolutions)


    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?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • I had it restricted to a particular category. It was a setting issue for me.

    • This reply was modified 1 week, 6 days ago by dailce.
    • This reply was modified 1 week, 6 days ago by dailce.
    • This reply was modified 1 week, 6 days ago by dailce.
    Plugin Author Mikko Saari

    (@msaari)

    Something on your site is restricting the search to those post types. That happens through the post_type query parameter, so you can simply override that:

    add_filter( 'relevanssi_modify_query', function( $query ) {
    $query->set( 'post_types', 'any' );
    return $query;
    } );

    This will make Relevanssi return all post types. It’s a good set-and-forget setting, as now the post types will be controlled by what is indexed and what is not.

    Thread Starter InterlockSolutions

    (@interlocksolutions)

    Thanks for pointing me in the right direction, Mikko. I had to make two minor tweaks to the code you sent to get it to work for me, but now the search is fully functional. I used the filter “relevanssi_modify_wp_query” and changed “any” to “page,post”. That did the trick. Here’s the final code:

    add_filter( 'relevanssi_modify_wp_query', function( $query ) {
    $query->set( 'post_types', 'page,post' );
    return $query;
    } );

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.