<p>You'd better double check for a typo because you actually got the syntax right for the <a href="http://buildwithcraft.com/docs/searching">search parameter</a>.</p>

<p><code>search('myField:myString')</code> filters all entries where a field with handle "myField" contains a string "myString". What you have should totally work to get the entries with a checkbox field handle "zone" and the value of the checkbox option being "pupil".</p>

<p>If you're sure that there's no typo and you actually have entries that match the criteria, I'd try if it helps to <a href="http://buildwithcraft.com/docs/searching#rebuilding-your-search-indexes">rebuild the search indexes</a> (tool in the CP settings). I actually try to avoid using the <code>search</code> parameter if possible, because things can go wrong with the indexes. Unfortunatelly I don't think there's other ways to filter by a checkbox field.</p>

<p>Other posibillity: If you don't want to paginate the entries or use other methods that are not available on custom arrays of entry models, what about filtering them with a simple conditional:</p>

<pre><code>{% set entries = craft.entries %}

{% for entry in entries if entry.zone.contains('pupil') %}
    {{ entry.title }}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-08-18T10:41:27.457Z
Thanks - rebuilding the index resolved the issue. 
In this section I am using these entries I only want the latest 7 entries. Which method uses least resources?
Doing the search parameter as I had originally done or using the other option you have? Then exiting the loop when 7 entries are listed,
mmc501
CC BY-SA 3.0
2014-08-18T11:03:47.513Z
If you use `search()`, you'll risk running into that indexes issue again. I'd avoid it if the other solution is an option for you, @mmc501.
carlcs
CC BY-SA 3.0
2014-08-18T08:08:19.387Z
2014-08-18T08:08:19.387Z
carlcs
<p>I have a section with entries which I wish to push to specific parts of the website.
I know I could filter them with a Category but the section already has a category so I would like to use checkboxes.</p>

<p>The checkbox only has 3 options so I could like to return those that are checked for a specific section.
Is this possible with checkboxes?
Been trying this but not getting anything returned:</p>

<pre><code>  {% set entries = craft.entries.section('newsMedia').order('postDate desc').limit(7).search('zone:pupil')%}
</code></pre>

<entries>
Can entries be returned based on checkbox selection?
# Can entries be returned based on checkbox selection?

(Asked by: username_0 on 2014-08-18)

I have a section with entries which I wish to push to specific parts of the website.
I know I could filter them with a Category but the section already has a category so I would like to use checkboxes.
The checkbox only has 3 options so I could like to return those that are checked for a specific section.
Is this possible with checkboxes?
Been trying this but not getting anything returned:
  {% set entries = craft.entries.section('newsMedia').order('postDate desc').limit(7).search('zone:pupil')%}

**Tags:** entries

---

## 1 answers

### Answer by username_1 on 2014-08-18. Score: 8 | Accepted answer

You'd better double check for a typo because you actually got the syntax right for the search parameter.
search('myField:myString') filters all entries where a field with handle "myField" contains a string "myString". What you have should totally work to get the entries with a checkbox field handle "zone" and the value of the checkbox option being "pupil".
If you're sure that there's no typo and you actually have entries that match the criteria, I'd try if it helps to rebuild the search indexes (tool in the CP settings). I actually try to avoid using the search parameter if possible, because things can go wrong with the indexes. Unfortunatelly I don't think there's other ways to filter by a checkbox field.
Other posibillity: If you don't want to paginate the entries or use other methods that are not available on custom arrays of entry models, what about filtering them with a simple conditional:
{% set entries = craft.entries %}

{% for entry in entries if entry.zone.contains('pupil') %}
    {{ entry.title }}
{% endfor %}

> **Comments:**
> **username_0**: Thanks - rebuilding the index resolved the issue.  In this section I am using these entries I only want the latest 7 entries. Which method uses least resources? Doing the search parameter as I had originally done or using the other option you have? Then exiting the loop when 7 entries are listed,  
> **username_1**: If you use `search()`, you'll risk running into that indexes issue again. I'd avoid it if the other solution is an option for you, @mmc501.  

---

