2

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.

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.