<p>My variable wasn't outputting the id and it wasn't being pulled into my omitIds variable</p>

<pre><code>{% set featuredIds = entry.featuredEntry.first.id %}

{% set omitIds = 'and, not ' ~ taggedEntries|join(', not ') ~ allEntries|join(', not ' ~ featuredIds) %}
</code></pre>

<p>Adding <code>.first.id</code> to my <code>entry.featuredEntry</code> outputs the correct id.
Then removed <code>featuredIds</code> from the <code>', not '</code> in omitIds and added <code>~ featuredIds</code> pulls in the correct id and omits it from the list.</p>

<p>Feel free to edit as I'm sure I'm not explaining this correctly.</p>

CC BY-SA 3.0
2017-03-22T02:56:20.373Z
2017-03-22T02:56:20.373Z
Tad Ward
<p>I have a homepage single section has a field for entries (only 1 can be selected).
This field is called featuredEntry.</p>

<p>In my homepage template (index.html) I set a variable <code>{% set featured = entry.featuredEntry %}</code> for the field
I then loop thru that to pull in that entries content <code>{% for mainEntry in featured %}</code></p>

<p>I have a listing of entries below it that pull from the same News channel as the featured entry above.
I don't want the featured entry to show in that list.</p>

<p>I followed the answer here (<a href="https://craftcms.stackexchange.com/questions/13821/exclude-featured-entries-from-a-recent-entries-for-loop">Exclude &quot;featured&quot; entries from a &quot;recent&quot; entries {% for %} loop</a>) with slight changes to try and omit that entry.</p>

<p>However, setting a variable <code>{% set featuredIds = featured.ids() %}</code> for the above featured entry doesn't seem to work.</p>

<p>I am omitting additional entries that are marked with a certain tag as explained here:
<a href="https://craftcms.stackexchange.com/questions/19428/list-entries-without-specific-tag">List entries without specific tag</a></p>

<p>What am I missing here or what is wrong for my code to not pull in that id of the featured entry?</p>

<pre><code>{% set featuredIds = featured.ids() %}

{% set mainTag = craft.tags.search('All-Stars').first() %}
{% set allEntries = craft.entries.section('news') %}
{% set taggedEntries = craft.entries.section('news').relatedTo(mainTag).ids %}

{% set omitIds = 'and, not ' ~ taggedEntries|join(', not ') ~ allEntries|join(', not featuredIds') %}
{% set untaggedEntries = craft.entries.section('news').id(omitIds) %}

{% for feedItems in untaggedEntries.limit(5) %}
</code></pre>

<p>In that code above in the omitIds variable, if I do this:
<code>{% set omitIds = 'and, not ' ~ taggedEntries|join(', not ') ~ allEntries|join(', not SPECIFIC ID') %}</code></p>

<p>It works.</p>

<p>Thanks in advance.</p>

<entries-field><id>
Omit Featured Entry from loop of entries with additional omissions
# Omit Featured Entry from loop of entries with additional omissions

(Asked by: username_0 on 2017-03-21)

I have a homepage single section has a field for entries (only 1 can be selected).
This field is called featuredEntry.
In my homepage template (index.html) I set a variable {% set featured = entry.featuredEntry %} for the field
I then loop thru that to pull in that entries content {% for mainEntry in featured %}
I have a listing of entries below it that pull from the same News channel as the featured entry above.
I don't want the featured entry to show in that list.
I followed the answer here (Exclude "featured" entries from a "recent" entries {% for %} loop) with slight changes to try and omit that entry.
However, setting a variable {% set featuredIds = featured.ids() %} for the above featured entry doesn't seem to work.
I am omitting additional entries that are marked with a certain tag as explained here:
List entries without specific tag
What am I missing here or what is wrong for my code to not pull in that id of the featured entry?
{% set featuredIds = featured.ids() %}

{% set mainTag = craft.tags.search('All-Stars').first() %}
{% set allEntries = craft.entries.section('news') %}
{% set taggedEntries = craft.entries.section('news').relatedTo(mainTag).ids %}

{% set omitIds = 'and, not ' ~ taggedEntries|join(', not ') ~ allEntries|join(', not featuredIds') %}
{% set untaggedEntries = craft.entries.section('news').id(omitIds) %}

{% for feedItems in untaggedEntries.limit(5) %}

In that code above in the omitIds variable, if I do this:
{% set omitIds = 'and, not ' ~ taggedEntries|join(', not ') ~ allEntries|join(', not SPECIFIC ID') %}
It works.
Thanks in advance.

**Tags:** entries-field, id


---

## 1 answers

### Answer by username_0 on 2017-03-22. Score: 1 | Accepted answer

My variable wasn't outputting the id and it wasn't being pulled into my omitIds variable
{% set featuredIds = entry.featuredEntry.first.id %}

{% set omitIds = 'and, not ' ~ taggedEntries|join(', not ') ~ allEntries|join(', not ' ~ featuredIds) %}

Adding .first.id to my entry.featuredEntry outputs the correct id.
Then removed featuredIds from the ', not ' in omitIds and added ~ featuredIds pulls in the correct id and omits it from the list.
Feel free to edit as I'm sure I'm not explaining this correctly.


---

