Ask your WordPress questions! Pay money and get answers fast! (more info)

Allow visitors to search by multiple tags (specific IDs) WordPress


I'm trying to create a search form/filter that allows visitors to search by specific tags.

I've implemented this solution:

<form method="get" action="<?php bloginfo('url'); ?>">
<input type="text" name="s" value="" placeholder="search…" maxlength="50" required="required" />
<p>Refine search to posts containing chosen tags:</p>
// generate list of tags
$tags = get_tags();
foreach ($tags as $tag) {
'<input type="checkbox" name="taglist[]" value="', $tag->slug, '" /> ',
<button type="submit">Search</button>

And this in functions.php:

// advanced search functionality
function advanced_search_query($query) {

if($query->is_search()) {

// tag search
if (isset($_GET['taglist']) && is_array($_GET['taglist'])) {
$query->set('tag_slug__and', $_GET['taglist']);

return $query;

add_action('pre_get_posts', 'advanced_search_query', 1000);

But it displays ALL tags. How would I get specific tags by ID for visitors to select?

Answers (1)


Balanean Corneliu answers:

Hy man i see you need more specific settings for that search. Why you dont buy a premium search with easy customization from wp-admin without coding.
[[LINK href=""]]Try Ajax Search Pro[[/LINK]]

drinkguesser comments:

Hi Balanean,

Because I only want to show specific tags for specific pages.

We have a travel company so on our lodging pages we would only want them to be able to select something like:

- Cabins
- Hotels
- Condos


- 1 star
- 2 star
- 3 star

You can see at the bottom of this page, what I currently have and that I'm trying to fix: