• Resolved m-one

    (@m-one)


    Rather than add filters to a results page I need to provide forms that search within a single category. So no user options – just a simple search box that only displays results from a category defined in the form parameters. Is this possible?

    Many thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Yes. Just add

    <input type="hidden" name="cats" value="X">

    where X is the numeric ID of your category, to your search form, and it will restrict the searches to that category.

    Thread Starter m-one

    (@m-one)

    Perfect – thanks so much!

    Thread Starter m-one

    (@m-one)

    Except unfortunately still returning results from all cats – anything wrong with my code:

    <form role="search" method="get" id="searchform" class="searchform" action="https://www.mysite.dev/"> 
    <label class="screen-reader-text" for="s">Search for:</label> 
    <input type="hidden" name="cats" value="CatName">
    <input type="text" value="" name="s" id="s" /> 
    <input type="submit" id="searchsubmit" value=">" /> 
    </form>

    Tried using cat slug and name – same result.

    • This reply was modified 7 years, 6 months ago by m-one.
    Thread Starter m-one

    (@m-one)

    Using cat ID works though – thanks.

    Plugin Author Mikko Saari

    (@msaari)

    Yes, “cats” will only accept category IDs.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘search form for single category’ is closed to new replies.