<p><strong>The most straightforward way would be to use a Categories field.</strong></p>

<p><strong>The value that a Categories field returns to the template is an <code>ElementCriteriaModel</code>, which fits perfectly as a value for the <code>.relatedTo</code> parameter.</strong></p>

<p>So you could do something like:</p>

<pre><code>{% set featuredEntries = craft.entries.relatedTo( entry.selectedCategories ) %}
</code></pre>

<p>The only circumstance where I can envision a Checkboxes field being better suited to this use-case is if you need to only provide a specific subset of the categories in a group.</p>

<p><em>(If you want to make all the categories from a group available for selection, using a Categories field is definitely best; otherwise you have to go back and update the options of your Checkboxes field every time a category is created, changed, or deleted.)</em></p>

<p>In that case, I recommend using the category IDs as the option values for your checkboxes, so that you can pass them to an <code>ElementCriteriaModel</code> like this:</p>

<pre><code>{% set featuredEntries = craft.entries.relatedTo( entry.selectedCheckboxes | join ) %}
</code></pre>

CC BY-SA 3.0
2016-09-03T17:14:43.467Z
Using the Categories field was definitely the best way to go about it, thanks for your help. No idea why I ruled out using the Categories field in the first place.
ChocolateOrange
CC BY-SA 3.0
2016-09-01T22:43:11.837Z
2016-09-01T22:43:11.837Z
Michael Rog
<p>I have a checkbox field to enable my client to choose what entry categories to have as an article feed on a page. How can I output the checked option categories when setting the entries in the for loop? Below is what I have done to return the checked option's value but what I want to do is use the checked options value to filter through entry categories.</p>

<p>What I'm looking to do is set the entries as below:</p>

<pre><code>{% set entries = craft.entries.relatedTo(category, 'checkedOptionValue','checkedOptionValue','checkedOptionValue').limit(10).find() %}

&lt;!-- This is returning the checked options value --&gt;
{% for option in checkboxFieldHandle.options %}
    {% if option.selected %}
        {{ option }}
    {% endfor %}
{% endfor %}
</code></pre>

<p>Any help would be greatly appreciated</p>

<checkboxes><set>
Get entries from client checked options
# Get entries from client checked options

(Asked by: username_0 on 2016-09-01)

I have a checkbox field to enable my client to choose what entry categories to have as an article feed on a page. How can I output the checked option categories when setting the entries in the for loop? Below is what I have done to return the checked option's value but what I want to do is use the checked options value to filter through entry categories.
What I'm looking to do is set the entries as below:
{% set entries = craft.entries.relatedTo(category, 'checkedOptionValue','checkedOptionValue','checkedOptionValue').limit(10).find() %}


{% for option in checkboxFieldHandle.options %}
    {% if option.selected %}
        {{ option }}
    {% endfor %}
{% endfor %}

Any help would be greatly appreciated

**Tags:** checkboxes, set


---

## 1 answers

### Answer by username_1 on 2016-09-01. Score: 2 | Accepted answer

The most straightforward way would be to use a Categories field.
The value that a Categories field returns to the template is an ElementCriteriaModel, which fits perfectly as a value for the .relatedTo parameter.
So you could do something like:
{% set featuredEntries = craft.entries.relatedTo( entry.selectedCategories ) %}

The only circumstance where I can envision a Checkboxes field being better suited to this use-case is if you need to only provide a specific subset of the categories in a group.
(If you want to make all the categories from a group available for selection, using a Categories field is definitely best; otherwise you have to go back and update the options of your Checkboxes field every time a category is created, changed, or deleted.)
In that case, I recommend using the category IDs as the option values for your checkboxes, so that you can pass them to an ElementCriteriaModel like this:
{% set featuredEntries = craft.entries.relatedTo( entry.selectedCheckboxes | join ) %}

> **Comments:**
> **username_0**: Using the Categories field was definitely the best way to go about it, thanks for your help. No idea why I ruled out using the Categories field in the first place.  

---

