<search> for Whole Words Only?

Hi everyone - long-time user, rare-poster here. Thanks for such great forums - they’ve been very helpful, but I am stuck again - and hoping this one’s an easy fix.

I’m trying to display the results of a search using “{Route part=1}” and it’s actually working TOO well - I’m getting every result where the route string is found, even if it’s not whole words:
Eg:
If the Route is “rary”, the loop displays every occurrence of that string, including “temporary”, “arbitrary”, etc.

Can I alter the loop to search for only whole words? At the beginning, middle and end of sentences would be ideal.

I haven’t found any means of concatenating the Route with a space, and I’m striking out using <format suffix> since I believe it’s only for output results.

Here’s the loop I’m using:

<If loop exists type=post sort_field=Timeline sort_order=desc sort_type=number search="{Route part=1}" exclude=current>

Thanks in advance for any ideas :slight_smile:

Hey there @turnerbuds, I’m glad you’re finding the forums helpful!

I think I might have missed the code you mentioned when you posted before. If you could send it again, that’d be awesome!

@ghen @turnerbuds looks like the code was there but wasn’t formatted as code so it was hidden. I’ve fixed the format in the original post so the code is now visible. Check out this post for more info on formatting code on the forum.

1 Like

Thank you kindly ) I guess I forgot to check my question afterwards )

@turnerbuds the search query parameter uses the core WordPress search functionality so if you want to modify what options are available to you through that parameter, you might want to look into third party scripts or plugins. I saw a plugin that adds the ability to search using regex but I don’t know how that would work in practice. L&L doesn’t currently include any features that modify the way WordPress handles searches.

Ultimately though, the search query parameter is always going to be very general and barebones. If you want to get more specific about which posts get displayed, you might want to look into other ways of organizing your content, such as using taxonomies or custom fields and then using the other query parameters on the post loop to filter your loop to include only specific results.

Let me know if you find a plugin that modifies WP’s search options in a way that meets your needs, I’d be curious to learn about that :slight_smile: