Is there a way to find out if an entry is enabled for a particular site?

I know there's the enabledForSite property, but it doesn't look like it accepts any arguments. Ideally I'd like to do something like {% if entry.enabledForSite(2) %} or {% if entry.enabledForSite('siteHandle') %}.


2 Answers 2


Based on the anyStatus and site query parameters, it should work like this:

{% set entries = craft.entries()
    .all() %}
  • Thanks @ChristopherDosin - however, this would allow me get all entries that are enabled for a particular site, rather than check if a particular entry is enabled for a particular site. I suppose I could do something like {% set count = craft.entries().id(entry.id).site('foo').enabledForSite(true).count() %} but it's not ideal
    – Pete H
    Oct 9, 2019 at 15:31
  • Why is this not ideal? This would be the query. Get your specific entry, from the specific site and check if it's enabled or not. What's wrong with the query? :) Oct 9, 2019 at 15:33
  • There's nothing wrong with the query. It's a lovely query. It just doesn't do what I need. Your query returns all entries that are enabled for the specified site. I need to check if a specific entry is enable for a specific site. The query I posted would work, but I don't love having to do a whole new query for something that should ideally be a property of the entry object I already have.
    – Pete H
    Oct 9, 2019 at 15:42
  • Unfortunately there's not such a parameter. enabledForSite accepts just true or false. I would just go with your query. Oct 9, 2019 at 15:45
  • OK thanks, appreciate your help :)
    – Pete H
    Oct 9, 2019 at 15:45

Just in case it helps anyone else, here's a reasonably efficient complete template I needed which outputs entries and their per-site statuses:

{% set entriesQuery = craft.entries

{% set uniqueEntries = clone(entriesQuery).unique().all()|index('id') %}

<title>Status Report</title>
<table border="1" cellpadding="5" cellspacing="0">
    {% for entryId, entryData in entriesQuery.all()|group('id') %}

        {% set somewhereIsEnabled = false %}

        {% set entrySitesStatuses %}            
            {% for entry in entryData %}
                {% set somewhereIsEnabled = entry.status == 'live' ? true : somewhereIsEnabled %}
                <li style="{{ entry.status == 'live' ? 'background:green' : 'text-decoration: line-through' }}">
                    {{ entry.site.handle }}: {{ entry.status }}
            {% endfor %}
        {% endset %}

        <tr style="{{ not somewhereIsEnabled ? 'background:red' }}">
            <td>{{ loop.index }}</td>
            <td>{{ uniqueEntries[entryId].id }}</td>
            <td>{{ uniqueEntries[entryId].title }}</td>
            <td>{{ uniqueEntries[entryId].status }}</td>
            <td><ul>{{ entrySitesStatuses }}</ul></td>
            <td>{{ uniqueEntries[entryId].type }}</td>
    {% endfor %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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