Restricting a search box to one category
Sometimes a site-wide search box is the wrong tool. A visitor reading your documentation wants to search the documentation. A visitor in a category sidebar wants to search that category. From 5.58 Super Speedy Search gives you three ways to build a search box that only searches part of your site, and they combine.
The three controls
| Control | Where | What it does |
|---|---|---|
| Restrict to Taxonomy | Widget table, or include_<taxonomy> | Always searches one specific term, wherever the box appears |
| Search what? | Widget dropdown, or search_what | Searches whatever archive the visitor is on, or its top-level parent |
| Show search suggestions dropdown | Widget checkbox, or suggestions | Turns the suggestion list off, which a restricted box usually wants |
All three restrict the ajax dropdown as well as the full results page.
Restrict to a fixed term
Use this when the box should always search the same section, no matter where it sits. Enter the taxonomy and term IDs in the widget’s Restrict to Taxonomy table, or use the shortcode:
[superspeedysearch include_product_cat="42" suggestions="off"]
Child terms are included automatically. Restricting to a parent category also finds items filed under its children, so you can point at the top of a section and not maintain a list.
You can name more than one taxonomy. Each is a separate restriction and all of them must match:
[superspeedysearch include_product_cat="42" include_product_brand="17"]
- A support search box on a product’s own page
- A brand-specific box on a brand landing page
- A “search this manual” box in documentation
Restrict to wherever the visitor is
Use this for one widget that behaves differently on every archive. Set Search what? to:
- Current page – searches the archive the visitor is on. A box in the Headphones category searches Headphones.
- Top category – searches that archive’s top-level parent. The same box searches all of Electronics.
Top category is usually the better choice for a sidebar on a deep category tree. A visitor browsing Electronics > Audio > Headphones who searches for a cable almost certainly wants the cable, not “no results in Headphones”. On a single product or post, both options use that item’s own category, so the box still works from a product page.
Neither option needs any per-category configuration. One widget in one sidebar adapts to every archive it appears on, so you are not maintaining a widget per category.
Turn suggestions off on a restricted box
This is the part people miss. The suggestion dropdown is built from a table of phrases harvested from every indexed title on your site. It has no idea which category any phrase came from, so it cannot be restricted – and a restricted box that still shows site-wide suggestions will send visitors straight out of the section they are searching.
So when you restrict a box, untick Show search suggestions dropdown (or pass suggestions="off"). The box still returns live results in its dropdown, correctly restricted – it just stops offering phrase suggestions it cannot honour.
This is a limitation of how suggestions are built, not a bug. Restricting them would mean maintaining a separate suggestion table per category, which would cost far more to rebuild than the feature is worth.
Which one do I want?
- The box always searches the same section, wherever it is → Restrict to Taxonomy
- One box, many category pages, should follow the visitor → Search what? → Current page or Top category
- Deep category tree and “no results” would be unhelpful → Top category
- Any of the above → also turn suggestions off
What was removed
The tax and taxslugs shortcode parameters were removed in 5.58. They were added in 2.05 and had stopped having any effect long before that, so a box using them looked restricted but searched the whole site. Replace them with include_<taxonomy>, which does what they promised and also restricts the dropdown.
[superspeedysearch tax="product_cat" taxslugs="dogs"] <- removed, did nothing
[superspeedysearch include_product_cat="42"] <- use this
include_<taxonomy> takes term IDs rather than slugs. You can find a term ID by opening it in Products > Categories and reading the tag_ID in the URL.

Comments