<p>This solution should also remove your "featured" category entries:</p>

<pre><code>{% set categories = craft.categories.relatedTo(entry) %}
{% set featuredCategory = craft.categories.slug('featured').first() %}

{% set allIds = [] %}
{% for id in categories.ids() if id != featuredCategory.id %}
    {% set allIds = allIds|merge([id]) %}
{% endfor %}

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

CC BY-SA 3.0
2015-07-31T17:35:19.827Z
Interesting, still getting featured though so not sure whats going on.
Bowenac
CC BY-SA 3.0
2015-07-31T17:51:19.663Z
Updated! Hope this finally works for you now. :)
carlcs
CC BY-SA 3.0
2015-07-31T17:28:18.430Z
2015-07-31T17:47:35.223Z
2015-07-31T17:47:35.223Z
carlcs
<p>Trying to get 10 entries related to the current entry categories excluding a category called featured. I don't have the category name(s) in the url.</p>

<p>This currently what I tried but this does not work, confused about how to do this.</p>

<pre><code>{# Fetch all of the categories related to this entry excluding the featured category#}
{% set categories = craft.categories.relatedTo(entry) %}

{# Output them #}
{% set thecategory = [] %}

{% for category in categories %}
    {% set thecategory = craft.categories.group('resource').slug(category.slug) %}
{% endfor %}

{# Set featured category name to exclude #}
{% set category = craft.categories.group('resource').title('featured') %}
{# Set featured ID's we dont want to show... #}
{% set featuredArticleIds = craft.entries.section('articles').relatedTo(category).ids() %}
{% set featuredArticleIdsString = featuredArticleIds | join(', not ') %}

{% set entries = craft.entries.section(articles).relatedTo('and', thecategory|join(',')).id('and, not '~featuredArticleIdsString).limit(10) %}
</code></pre>

<templating><entries><categories>
Getting entries related to current entries categories
# Getting entries related to current entries categories

(Asked by: username_0 on 2015-07-31)

Trying to get 10 entries related to the current entry categories excluding a category called featured. I don't have the category name(s) in the url.
This currently what I tried but this does not work, confused about how to do this.
{# Fetch all of the categories related to this entry excluding the featured category#}
{% set categories = craft.categories.relatedTo(entry) %}

{# Output them #}
{% set thecategory = [] %}

{% for category in categories %}
    {% set thecategory = craft.categories.group('resource').slug(category.slug) %}
{% endfor %}

{# Set featured category name to exclude #}
{% set category = craft.categories.group('resource').title('featured') %}
{# Set featured ID's we dont want to show... #}
{% set featuredArticleIds = craft.entries.section('articles').relatedTo(category).ids() %}
{% set featuredArticleIdsString = featuredArticleIds | join(', not ') %}

{% set entries = craft.entries.section(articles).relatedTo('and', thecategory|join(',')).id('and, not '~featuredArticleIdsString).limit(10) %}

**Tags:** templating, entries, categories


---

## 1 answers

### Answer by username_1 on 2015-07-31. Score: 3 | Accepted answer

This solution should also remove your "featured" category entries:
{% set categories = craft.categories.relatedTo(entry) %}
{% set featuredCategory = craft.categories.slug('featured').first() %}

{% set allIds = [] %}
{% for id in categories.ids() if id != featuredCategory.id %}
    {% set allIds = allIds|merge([id]) %}
{% endfor %}

{% set entries = craft.entries.relatedTo(allIds) %}

> **Comments:**
> **username_0**: Interesting, still getting featured though so not sure whats going on.  
> **username_1**: Updated! Hope this finally works for you now. :)  

---

