Filtering Search Results by Category I'm currently trying to filter my search results by category, I've been following this tutorial but cannot get it to work. It keeps not adding on the category parameter, but instead just replaces the search parameter like so:

On search:
"/search/?q=dress"

On Clicking a Filter:
"/search/?category=wedges"

Below is the code running my search box:

&lt;div class="search-box w-form"&gt;
  &lt;form action="search/" class="form"&gt;
    &lt;input type="text" class="text-field w-input" maxlength="256" type="search" autofocus="true" name="q" data-name="Name" placeholder="e.g. Black Dress" id="name"&gt;
    &lt;input type="submit" data-wait="Please wait..." class="search-field-go w-button" value=""&gt;
  &lt;/form&gt;
&lt;/div&gt;


and the code running the results page:

{% set query = craft.request.getParam('q') %}
{% if craft.request.getParam('category') is not null %}
    {% set category = craft.categories.slug(craft.request.getParam('category')) %}
    {% set entries = craft.entries.search(query).order('score').relatedTo(category).find() %}
{% else %}
    {% set entries = craft.entries.search(query).order('score') %}
{% endif %}

{% include 'search/_filters' %}

&lt;!-- SEARCH CONTAINER --&gt;

{% if entries|length %}
    &lt;p&gt;{{ entries|length }} results:&lt;/p&gt;

    &lt;ul&gt;
        {% for entry in entries %}
            &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
{% else %}
    &lt;p&gt;Your search for “{{ query }}” didn’t return any results.&lt;/p&gt;
{% endif %}

&lt;ul&gt;
   {% for category in craft.categories.group('womens').find() %}
    &lt;li&gt;
            &lt;a href="{{craft.request.url}}/?category={{ category.slug }}"&gt;{{ category.title}} &lt;/a&gt;
         &lt;/li&gt;
  {% endfor %}
&lt;/ul&gt;
In this line here (reformatted for legibilty):

&lt;a href="{{craft.request.url}}/?category={{ category.slug }}"&gt;
  {{ category.title}}
&lt;/a&gt;


You are generating the url by from craft.request.url and appending the category. But the original query is not part of the url at this point. I think this will work and be clearer:

&lt;a href="{{ url(craft.request.path, {q: query, category: category.slug}) }}"&gt;
  {{ category.title}}
&lt;/a&gt;


This uses the url function, passing it the query string parameters.