<p>I might be missing something, but your code is missing a <code>{% for entry in entries %}</code> loop wrapped around your <code>&lt;div&gt;</code>.</p>

CC BY-SA 3.0
2017-04-28T08:52:39.780Z
2017-04-28T08:52:39.780Z
Mike Pierce
<p>I have four category groups (Position, State, Status, Denomination). I am trying to create a search form so all four categories can be utilized together or individually.</p>

<p>Here is what I have for my form:</p>

<pre><code>&lt;form action="{{ url('ministry-jobs/results') }}"&gt;

&lt;input type="search" name="query" placeholder="What are you looking for?" style="width: 100%;"&gt;

&lt;select name="position[]"&gt;
  &lt;option value="" selected&gt;-- Select Position --&lt;/option&gt;
  {% set positions = craft.categories.group('position') %}
  {% for position in positions %}
  &lt;option value="{{ position.slug }}"&gt;{{ position.title }}&lt;/option&gt;
  {% endfor %}
&lt;/select&gt;

&lt;select name="state[]"&gt;
  &lt;option value="" selected&gt;-- Select State --&lt;/option&gt;
  {% set states = craft.categories.group('state') %}
  {% for state in states %}
  &lt;option value="{{ state.slug }}"&gt;{{ state.title }}&lt;/option&gt;
  {% endfor %}
&lt;/select&gt;

&lt;select name="status[]"&gt;
  &lt;option value="" selected&gt;-- Select Status --&lt;/option&gt;
  {% set statuses = craft.categories.group('status') %}
  {% for status in statuses %}
  &lt;option value="{{ status.slug }}"&gt;{{ status.title }}&lt;/option&gt;
  {% endfor %}
&lt;/select&gt;

&lt;select name="denomination[]"&gt;
  &lt;option value="" selected&gt;-- Select Denomination --&lt;/option&gt;
  {% set denominations = craft.categories.group('denomination') %}
  {% for denomination in denominations %}
  &lt;option value="{{ denomination.slug }}"&gt;{{ denomination.title }}&lt;/option&gt;
  {% endfor %}
&lt;/select&gt;

&lt;div class=""&gt;
  &lt;input type="submit" value="Search"&gt;
&lt;/div&gt;
</code></pre>

<p></p>

<p>And here is what I have on Results Page:</p>

<pre><code>{% set query = craft.request.getParam('q') %}
{% set position = craft.request.getParam('position') %}
{% set state = craft.request.getParam('state') %}
{% set status = craft.request.getParam('status') %}

{% set homeGrownParam = craft.request.getParam('homeGrown') %}
{% set preparedProduceParam = craft.request.getParam('preparedProduce') %}
{% set redTractorParam = craft.request.getParam('redTractor') %}

{% set positionCat = position ? craft.categories.group('position').slug(position).find() %}
{% set stateCat = state ? craft.categories.group('state').slug(state).find() %}
{% set statusCat = status ? craft.categories.group('status').slug(status).find() %}

{% set positionParam = positionCat ? {targetElement: ['and']|merge(positionCat)} %}
{% set stateParam = stateCat ? {targetElement: ['and']|merge(stateCat)} %}
{% set statusParam = statusCat ? {targetElement: ['and']|merge(statusCat)} %}

{% set relationParams = [positionParam, stateParam, statusParam]|filter %}

{% set entries = craft.entries({
    section: 'ministryJobs',
    relatedTo: relationParams ? ['and']|merge(relationParams) : null,
    search: query,
    homeGrown: homeGrownParam,
    preparedProduce: preparedProduceParam,
    redTractor: redTractorParam
}) %}

&lt;div class="{{ cycle(['job-display-white', 'job-display-grey'], loop.index0) }}"&gt;

    &lt;a href="{{ entry.url }}"&gt;
        &lt;div class="col-1 post-data"&gt;{{ entry.postDate.format("m/d/y") }}&lt;/div&gt;
        &lt;div class="col-2 post-data job-position"&gt;{{ entry.position }}&lt;/div&gt;
        &lt;div class="col-3 post-data"&gt;{{ entry.church }}&lt;/div&gt;
        &lt;div class="col-4 post-data"&gt;{{ entry.city }}&lt;/div&gt;
        &lt;div class="col-5 post-data"&gt;{{ entry.state }}&lt;/div&gt;
        &lt;div style="clear: both;"&gt;&lt;/div&gt;
    &lt;/a&gt;

&lt;/div&gt;
</code></pre>

<p>I am getting no results. I am not sure what I am doing wrong. Any help is greatly appreciated.</p>

<templating>
Searching Multiple Categories in Craft CMS
# Searching Multiple Categories in Craft CMS

(Asked by: username_0 on 2017-04-27)

I have four category groups (Position, State, Status, Denomination). I am trying to create a search form so all four categories can be utilized together or individually.
Here is what I have for my form:





  -- Select Position --
  {% set positions = craft.categories.group('position') %}
  {% for position in positions %}
  {{ position.title }}
  {% endfor %}



  -- Select State --
  {% set states = craft.categories.group('state') %}
  {% for state in states %}
  {{ state.title }}
  {% endfor %}



  -- Select Status --
  {% set statuses = craft.categories.group('status') %}
  {% for status in statuses %}
  {{ status.title }}
  {% endfor %}



  -- Select Denomination --
  {% set denominations = craft.categories.group('denomination') %}
  {% for denomination in denominations %}
  {{ denomination.title }}
  {% endfor %}



  



And here is what I have on Results Page:
{% set query = craft.request.getParam('q') %}
{% set position = craft.request.getParam('position') %}
{% set state = craft.request.getParam('state') %}
{% set status = craft.request.getParam('status') %}

{% set homeGrownParam = craft.request.getParam('homeGrown') %}
{% set preparedProduceParam = craft.request.getParam('preparedProduce') %}
{% set redTractorParam = craft.request.getParam('redTractor') %}

{% set positionCat = position ? craft.categories.group('position').slug(position).find() %}
{% set stateCat = state ? craft.categories.group('state').slug(state).find() %}
{% set statusCat = status ? craft.categories.group('status').slug(status).find() %}

{% set positionParam = positionCat ? {targetElement: ['and']|merge(positionCat)} %}
{% set stateParam = stateCat ? {targetElement: ['and']|merge(stateCat)} %}
{% set statusParam = statusCat ? {targetElement: ['and']|merge(statusCat)} %}

{% set relationParams = [positionParam, stateParam, statusParam]|filter %}

{% set entries = craft.entries({
    section: 'ministryJobs',
    relatedTo: relationParams ? ['and']|merge(relationParams) : null,
    search: query,
    homeGrown: homeGrownParam,
    preparedProduce: preparedProduceParam,
    redTractor: redTractorParam
}) %}



    
        {{ entry.postDate.format("m/d/y") }}
        {{ entry.position }}
        {{ entry.church }}
        {{ entry.city }}
        {{ entry.state }}
        
    



I am getting no results. I am not sure what I am doing wrong. Any help is greatly appreciated.

**Tags:** templating


---

## 1 answers

### Answer by username_1 on 2017-04-28. Score: 0 | Accepted answer

I might be missing something, but your code is missing a `{% for entry in entries %}` loop wrapped around your .


---

