Search query not working with Relevanssi plugin

Search query not working with Relevanssi plugin (Relevanssi – A Better Search – WordPress plugin |

Code -

<Loop search="{Url query=s}" type=color count=8>
  <div class="boxc">
		<a href="{Field url}">

<div style="background: {Field color_hex};" class="hexc"><p><Field hex /></p></div>
		<p class="boxcp"><Field color_name /></p>

The search function also doesn’t get updated with " Ivory Search" plugin.

The current search functionality is very limited. I would like to search relevant content based on OR logic, it should search for added post categories, custom fields, etc.

Hi @xtreamprince, welcome to the forum! I haven’t used Relevanssi or Ivory Search myself, but I assume the reason you’d be using those plugins is so that you can control how the search query works on your site using a graphical interface. However, I’m pretty sure what’s happening in the template you shared (in the <Loop search="{Url query=s}" type=color count=8> part of it) is that you’re creating a new search query using L&L, essentially ignoring the one created by Relevanssi or some other plugin.

What your L&L template is doing is that it’s looking for a parameter in your URL (let’s say your URL is and then it’s passing the value of that parameter (in my example, blue) to some kind of search query. I’m not a dev so I don’t know what underlying functions it’s tapping into, but I assume it’s just using some core WordPress search function. If the L&L template isn’t working for you, are you sure there’s a ?s= parameter in the URL of the page where you’re loading that template? If there is, maybe you can try just writing <Url query=s /> in your template and see if it’s displaying the value of that parameter or not. If not, maybe you could try <Url current /> and see if it’s actually displaying the correct current URL you’re expecting or if it’s displaying something else.

As far as extending the search functionality, you’re right that this would be useful, but given the other big priorities on the roadmap, I’m not sure how soon we’ll be able to implement that. I think in the short term, your best bet is probably going to be to use a third-party plugin that modifies what gets searched when a user enters a keyword in your site’s search. Then, if you want to use L&L to display the results from that query, you can just write <Loop> by itself with no additional query parameters and that will rely on the current page’s default query. This will only work if the plugin you’re using uses the standard wp_query system, but most well-designed plugins will work that way. For info about how that works, check out the “Loops without a specified type” section in the docs for the Loop tag.

I hope that’s helpful in guiding you toward an approach here!