So I hope I am explaining this correctly.

I have some entries with a tag called 'hidden'. In my blog layout I want to exclude those entries.

I have the following:

{% set tag = craft.tags.name('hidden') %}
{% set hiddenentry = craft.entries.section('blog').relatedTo(tag).find() %}
{% set allentry = craft.entries.section('blog').limit(5).find() %}
{% set unhidden = allentry|without(hiddenentry) %}

{% for entry in unhidden %}
    <div class="content">
            <h2><a href="{{ entry.url }}">{{ entry.title }}</a></h2>
            <p class="date">Posted on {{ entry.postDate.format('F d, Y') }}</p>
            {{ entry.body.getPage(1) }}
            {# {{ entry.summary }} #}
            <button><a href="{{ entry.url }}">Continue reading</a></button>
{% endfor %}

Not really the answer you are looking for, but it might be easier to change the tag hidden to a checkbox or lightswitch field and add a condition to the for..in loop, as explained in the twig documentation, which may do what you need and keep the query count lower.

{% for entry in allEntries if not entry.hidden %}
{% endfor %}

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.