Search, custom taxonomy 'all selected taxonomy terms'
-
Hello,
Below is the code for my advanced search page which has checkboxs for categories and custom tags. What I want it to do with the Facilities taxonomy is when multiple are selected it will only return posts that are marked with all the selected tags.
At the moment it it will pass back all posts that contain one or more of the selected facilities.
so it seems to be searching ‘or’ instead of ‘and’ if you get what I mean.
I can’t seem to figure it out, any help?
<form role="search" method="get" id="Advsearchform" action="{$homeUrl}"> <div> <label id="AdvSeaBox"><!-- for="s">Search for:--> <input type="text" value="" name="s" id="s" />Search for:</label> <!--put category id in the value*/--> <div id="AdvSearchCat"> <h2>In</h2> <ul> <li><label><input type="checkbox" name="categories" id="dir-searchinput-category-id" value="5"><span class="SeaCatIcon" id="AdSeoAtt"></span><p>Attractions</p></label></li> <li><label><input type="checkbox" name="categories" id="dir-searchinput-category-id" value="6"><span class="SeaCatIcon" id="AdSeoStay"></span><p>Places to stay</p></label></li> <li><label><input type="checkbox" name="categories" id="dir-searchinput-category-id" value="7"><span class="SeaCatIcon" id="AdSeoEat"></span><p>Places to eat</p></label></li> </ul> </div> <div id="AdvSearchLoco"> <h2>Location</h2> <ul> <?php // The following will list all locations with a checkbox next to them. $locos = get_terms( 'ait-dir-item-location' ); $checkboxes = ''; foreach($locos as $loco) : $checkboxes .='<li><input type="checkbox" name="locations" value="'.$loco->term_id.'" id="tag-'.$loco->term_id.'" /><label for="tag-'.$loco->term_id.'">'.$loco->name.'</label></li>'; endforeach; print $checkboxes; ?> <li><label><input type="checkbox" name="All" id="dir-searchinput-location-id" value="8,10,11,12">All Locations</label></li> </ul> </div> <div id="AdvSearchFaci"> <h2>Facilities</h2> <ul> <?php // The following will list all facilities tags with a checkbox next to them. $tags = get_terms( 'facilities' ); $checkboxes = ''; foreach($tags as $tag) : $checkboxes .='<li><label for="tag-'.$tag->term_id.'"><input type="checkbox" name="facilities" value="'.$tag -> slug.'" id="tag-'.$tag->term_id.'" /><span class="FacIcons" id="Icon-'.$tag-> slug.'"></span>'.$tag->name.'</label></li>'; endforeach; print $checkboxes; ?> </ul> </div> <input type="submit" id="Advsearchsubmit" value="Search" /> </div> </form>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Search, custom taxonomy 'all selected taxonomy terms'’ is closed to new replies.