‘+’ sign will work on url. eg: site.com/tag/cats+dogs+bananas
.
but am confused on how to feed multiple selections into url. guess you will need a JS to handle input name values in array[]? lets see if anybody can add in..
<form action="<?php get_site_url(); ?>">
<input type="checkbox" name="tag" value="cats">cats<br>
<input type="checkbox" name="tag" value="dogs">dogs<br>
<input type="submit" value="submit">
</form>
ok try this:
add this code to where you want to display tags checkbox:
<form action="yoursite.com/tagsredirect.php" method="post">
<?php $tags = get_tags();
foreach ( $tags as $tag ) {
echo "<input type=\"checkbox\" name=\"$tag->name\" value=\"$tag->slug\">$tag->name<br />";
} ?>
<input type="submit" value="submit">
</form>
now create a new file called tagsredirect.php and place it in your webserver (note the full URL to this file and put it in above code).
add this code to tagsredirect.php file:
<?php
$myurl = 'http://yourwebsite.com/tag/'.implode("+",$_POST);
header("Location: $myurl");
exit;
?>
thats it. try if this works.
Note: depending on how many tags you have, the first loop of generating input elements for all tags could be freakishly huge.
also, hope you are proficient with coding. else, take proper backups and work with a child theme.
Wow, you’re quick! Thank you!
Okay, I finally put together a dummy installation to test this out, and it’s not quite right.
First, the structure of “site.com/tag/cats+dogs+bananas” brings up a 404 on my site. I discovered that “site.com/?tag=cats+dogs+bananas” works, but it brings up every post that has ANY of those tags.
I want something that works like Webtender’s “in my bar” feature, which is probably custom code, and definitely not WordPress. People enter what ingredients they have on hand, and it brings up only recipes that can be made with those ingredients.
In terms of tags, that would mean a script that brings up only recipes that do NOT contain tags OTHER than the ones selected. It’s more like an exclusion filter than a search. I have no idea if WordPress can be made to work like that. :/
first step first.. you use the ‘?’ if you are not using custom permalinks.
if ‘,’ acts as an OR gate and ‘+’ as an AND gate. i tried this code on my site and it works. so recheck once more on yours. also check if you are using ‘slugs’ and not names of tags.
Aha, I hadn’t set up custom permalinks on the dummy install. Now I have, and it works as an and gate or an or gate.
However, what I need is different. It’s my fault for failing to understand and communicate it clearly. I guess the simplest way to phrase what I need is: something that EXCLUDES all tags that were NOT selected by the user. Can WordPress do that at all? I’m find with using categories instead of tags or anything that’ll work.
Taking another look at the Webtender example I shared above, they have a Javascript file which seems to use tags, so it would seem it’s possible to do this with a WP database…. just might require a totally separate script to do it.
then pls close this thread and start a new one with proper title.
I don’t see an option to “close” the thread. I see “resolved”, but that would be misleading.