<p>As @Youniteus stated in a comment to this post the answer was related to <a href="https://craftcms.stackexchange.com/questions/1758/what-is-the-best-way-to-exclude-an-array-of-entries">this question</a></p>

<p>I had to tweak the join statements a bit but it's working now.</p>

<p>complete code here:</p>

<pre><code>{# convert array to string  so we can remove these ids #}
{% set excludedJobs = excludeRelatedJobs|join(', not ') %}

{# set careers to all jobs created by author#}
{% if not excludedJobs|length%} 
    {% set careers = craft.entries.section('careers').authorId(user.id) %}

{# filter out jobs already added to store#}
{% else %}
    {% set careers = craft.entries.section('careers').authorId(user.id).id('and, not ' ~ excludedJobs) %}
{% endif %}

&lt;ul&gt;
    {% for job in careers %}
    &lt;li&gt;&lt;a href="/careers/edit/{{ job.id }}"&gt;{{ job.title }}&lt;/a&gt;&lt;/li&gt;
    {% endfor %}
&lt;/ul&gt;
</code></pre>

CC BY-SA 3.0
2017-08-16T16:12:23.283Z
2017-08-16T16:12:23.283Z
CreateSean
<p>I am attempting to list out all jobs that the current author has created but which are not already to other entries they've created.</p>

<p>I have both an array and a string containing the entry ids to exclude which I can see with these tags:</p>

<pre><code>{# delete later, only here to visually show entry ids while coding #}
&lt;p&gt;&lt;strong&gt;array:&lt;/strong&gt; {{ excludeRelatedJobs|join(', ') }}&lt;/p&gt;

{# convert array to string #}
{% set excludedJobs = excludeRelatedJobs|join(', ') %}

&lt;p&gt;&lt;strong&gt;string:&lt;/strong&gt; {{ excludedJobs }}&lt;/p&gt;
</code></pre>

<p>However when I try to exclude the ids from the list they are not excluded.</p>

<p>current code that should exclude ids:</p>

<pre><code>{% set careers = craft.entries.section('careers').authorId(user.id).id('not' ~ excludedJobs) %}
&lt;ul&gt;
    {% for job in careers %}
    &lt;li&gt;&lt;a href="/careers/edit/{{ job.id }}"&gt;{{ job.title }}&lt;/a&gt;&lt;/li&gt;
    {% endfor %}
&lt;/ul&gt;
</code></pre>

<p>If I manually exclude the id like this it works correctly:</p>

<p>{% set careers = craft.entries.section('careers').authorId(user.id).id('not 581') %}</p>

CC BY-SA 3.0
2017-08-14T18:53:43.477Z
I think that this question is related to your problem:
https://craftcms.stackexchange.com/questions/1758/what-is-the-best-way-to-exclude-an-array-of-entries
Youniteus
CC BY-SA 3.0
2017-08-14T19:48:58.143Z
I based my code on that post. but it wasn't working
CreateSean
CC BY-SA 3.0
2017-08-14T19:58:59.880Z
Seems you need to have an "and" in there: … id('and, not' ~ excludedJobs)
KSP
CC BY-SA 3.0
2017-08-14T20:31:45.187Z
I did have that but when I do it doesn't list anything at all even when it should.
CreateSean
<templating><id>
exclude list of entries from craft.entries tag
# exclude list of entries from craft.entries tag

(Asked by: username_0 on 2017-08-14)

I am attempting to list out all jobs that the current author has created but which are not already to other entries they've created.
I have both an array and a string containing the entry ids to exclude which I can see with these tags:
{# delete later, only here to visually show entry ids while coding #}
array: {{ excludeRelatedJobs|join(', ') }}

{# convert array to string #}
{% set excludedJobs = excludeRelatedJobs|join(', ') %}

string: {{ excludedJobs }}

However when I try to exclude the ids from the list they are not excluded.
current code that should exclude ids:
{% set careers = craft.entries.section('careers').authorId(user.id).id('not' ~ excludedJobs) %}

    {% for job in careers %}
    {{ job.title }}
    {% endfor %}


If I manually exclude the id like this it works correctly:
{% set careers = craft.entries.section('careers').authorId(user.id).id('not 581') %}

**Tags:** templating, id
> **Comments:**
> **username_1**: I think that this question is related to your problem: https://craftcms.stackexchange.com/questions/1758/what-is-the-best-way-to-exclude-an-array-of-entries  
> **username_0**: I based my code on that post. but it wasn't working  
> **username_2**: Seems you need to have an "and" in there: … id('and, not' ~ excludedJobs)  
> **username_0**: I did have that but when I do it doesn't list anything at all even when it should.  

---

## 1 answers

### Answer by username_0 on 2017-08-16. Score: 1 | Accepted answer

As @Youniteus stated in a comment to this post the answer was related to this question
I had to tweak the join statements a bit but it's working now.
complete code here:
{# convert array to string  so we can remove these ids #}
{% set excludedJobs = excludeRelatedJobs|join(', not ') %}

{# set careers to all jobs created by author#}
{% if not excludedJobs|length%} 
    {% set careers = craft.entries.section('careers').authorId(user.id) %}

{# filter out jobs already added to store#}
{% else %}
    {% set careers = craft.entries.section('careers').authorId(user.id).id('and, not ' ~ excludedJobs) %}
{% endif %}


    {% for job in careers %}
    {{ job.title }}
    {% endfor %}


---

