duane-dunn
Forum Replies Created
-
Forum: Plugins
In reply to: Custom Query for Multiple Tags and Custom FieldI thought I’d document the way I got this to work without much trouble.
I made use of the plugin “TDO Tags Fixes” which adds functionality for searching with category and tag intersections. You just install, activate it, and it does it’s magic.
I used the functionality described here in it’s readme file
So go to one of your category pages. If your using using fancy permalinks then at the end of the url add “
?tdo_tag=a_tag
“. You must use the tag slug, not the full tag name. You can use multiple tags as above using “,” and “+”.* Example using fancy permalinks: “
https://your-blog-uri/category/mycategory/?tdo_tag=tag1+tag2
” this would get all posts in the category “mycategory” and tagged with both tag1 and tag2.I wanted to have a form that would present a drop down with categories and an area below that where all tags were listed with checkboxes.
The user selects the category they want to search in and selects one or more tags they want to find.
Making the form was straight forward and is just simple html. I used the ‘Post” method and pointed the action to a php file I made called INeed.php, you could of course use any name you want for the file.
The INeed.php file receives the category chosen as a simple $_post variable. It receives the tags chosen as an $_post array.
From these I then build a url that points to the category and includes a call to “?tdo_tag” to pull the posts with those tags.
Once I have this url I make a header call with it as the location and the page displays all posts in the category chosen that have all the selected tags.
I was able to easily implement this both on a search page and in a sidebar using the “PHP Custom Widget” that allowed me to place the html form code inside it.
Here is the code I used in INeed.php.
$searchcategory = $_POST["searchcategory"]; $searchtag = $_POST["searchtag"]; If (empty($searchtag)) { $url = "https://yoursite.com/archives/category/" . $searchcategory; } else $counter = 1; { foreach ($searchtag as $value) { if ($counter == 1) { $searchtags = $value; $counter += 1; } else { $searchtags = $searchtags . "+" . $value; $counter += 1; } } $url = "https://yoursite.com/archives/category/" . $searchcategory . "/?tdo_tag=" . $searchtags; } header("Location: $url"); ?>
Forum: Plugins
In reply to: Custom Query for Multiple Tags and Custom FieldI am trying to do a very similar thing.
I see on your site you have implemented a search box just like I want to in your sidebar. How did you do this? Did you use a particular widget or plugin?
I want to have categories in the top drop down, and tags in the larger window below.
Please post any code, link, or instructions that helped you figure out how to do this.
I’ve searched and searched without finding a way to do this.
Thanks for your help.