I am trying to output a list of entries from a channel section that DO NOT have a certain tag.
I am able to output the entries that have the tag assigned by setting the tag as a variable and using relatedTo
to filter the entries out. For example:
{% set tag = craft.tags.search('All-Stars').first() %}
{% if tag %}
{% set relatedEntries = craft.entries.section('news').relatedTo(tag) %}
{% endif %}
What is the best approach to output entries without the tag? I've tried the following:
{% set tag = craft.tags.search('All-Stars').first() %}
{% set allEntries = craft.entries.section('news') %}
{% set taggedEntries = craft.entries.section('news').relatedTo(tag) %}
{% set untaggedEntries = allEntries|without(taggedEntries) %}
{% for feedItems in untaggedEntries.limit(5).offset(1) %}
This however doesn't work and throws out some errors, the first being:
array to string conversion
craft/app/vendor/twig/twig/lib/Twig/Template.php(525)
$message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s")', $item, gettype($object), $object);
I tried many other ideas like .relatedTo('not' ~ tag)
and |without
with no avail.
Is it something obvious I am missing or more advance than that?
Thanks in advance