Answers.Body: <p>Out of the box, Craft won't even load your <code>_entry.html</code> file for a disabled entry – it'll just throw a 404.</p>
  
  <p>To work around that, you can create a <a href="https://craftcms.com/docs/routing#dynamic-routes" rel="noreferrer">dynamic route</a> which matches the entry type URL format 1:1, and point that route to the same template (i.e. <code>_entry.html</code>).</p>
  
  <p>For instance, if your entry type's URL format is <code>news/{postDate.year}/{slug}</code>, you'd create a dynamic route using the "year" and "slug" tokens (i.e. <code>news/(year)/(slug)</code>). Then, Craft will automatically match your dynamic route whenever an entry URL <em>doesn't</em> (e.g. when the entry is disabled).</p>
  
  <p>You're not home free yet, though – as you're probably aware, Craft automatically populates a template with an <code>entry</code> variable whenever the current URL request matches an entry type's URL format, and an enabled entry is found at that URL. This won't be the case for any entries matched by your dynamic route, so put this at the top of your template (replacing the line in your question!):</p>
  
  <pre><code>{% set entry = entry ?? slug ? craft.entries.section('yourSectionHandle').slug(slug).status(null).first() %}
  {% if not entry %}
      {% exit 404 %}
  {% endif %}
  </code></pre>
  
  <p>What the above does, is to test for the <code>entry</code> variable Craft would set if the entry was enabled. If that evaluates to <code>false</code>, then it checks to see if there's a <code>slug</code> variable set – which there will be if the URL was matched by the dynamic route. If there is a slug, it'll then attempt to pull the entry using <code>craft.entries</code>, similar to your initial code. Finally, if an entry is <em>not</em> found, it'll throw a 404 error, as it should.</p>
  
  <p>In your template, you can easily test for the entry's status:</p>
  
  <pre><code>{% if not entry.enabled %}
      &lt;p&gt;Danger danger! I am disabled!&lt;/p&gt;
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-15T16:54:06.507Z
Answers.Text: That's awesome.  Works perfectly.  Thanks for the quick response.
Answers.UserDisplayName: Matt Price
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-15T17:06:38.703Z
Answers.Text: That's great! I added a little ting in my answer – it's probably a good idea to include `.section('yourSectionHandle')` in the `craft.entries` query, as entries belonging to different sections can have identical slugs.
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2016-07-15T16:49:01.360Z
Answers.LastActivityDate: 2018-07-23T16:41:42.287Z
Answers.LastEditDate: 2018-07-23T16:41:42.287Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I am trying to view an entry, even if it disabled on the front end but having no luck.</p>
  
  <p>On the _entry.html (which works perfectly for entries that are live), I have tried the following.  Am I missing something?</p>
  
  <pre><code>{% set entry = craft.entries.slug(entry.slug).status(null).first %}
  </code></pre>
  
  <p>Thanks</p>
  
Tags: <entries>
Title: Display an entry page if entry is disabled
ThreadText: # Display an entry page if entry is disabled
  
  (Asked by: username_0 on 2016-07-15)
  
  I am trying to view an entry, even if it disabled on the front end but having no luck.
  
  On the \_entry.html (which works perfectly for entries that are live), I have tried the following. Am I missing something?
  
  ```
  {% set entry = craft.entries.slug(entry.slug).status(null).first %}
  
  ```
  
  Thanks
  
  **Tags:** entries
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-07-15. Score: 10 | Accepted answer
  
  Out of the box, Craft won't even load your `_entry.html` file for a disabled entry – it'll just throw a 404.
  
  To work around that, you can create a [dynamic route](https://craftcms.com/docs/routing#dynamic-routes) which matches the entry type URL format 1:1, and point that route to the same template (i.e. `_entry.html`).
  
  For instance, if your entry type's URL format is `news/{postDate.year}/{slug}`, you'd create a dynamic route using the "year" and "slug" tokens (i.e. `news/(year)/(slug)`). Then, Craft will automatically match your dynamic route whenever an entry URL *doesn't* (e.g. when the entry is disabled).
  
  You're not home free yet, though – as you're probably aware, Craft automatically populates a template with an `entry` variable whenever the current URL request matches an entry type's URL format, and an enabled entry is found at that URL. This won't be the case for any entries matched by your dynamic route, so put this at the top of your template (replacing the line in your question!):
  
  ```
  {% set entry = entry ?? slug ? craft.entries.section('yourSectionHandle').slug(slug).status(null).first() %}
  {% if not entry %}
      {% exit 404 %}
  {% endif %}
  
  ```
  
  What the above does, is to test for the `entry` variable Craft would set if the entry was enabled. If that evaluates to `false`, then it checks to see if there's a `slug` variable set – which there will be if the URL was matched by the dynamic route. If there is a slug, it'll then attempt to pull the entry using `craft.entries`, similar to your initial code. Finally, if an entry is *not* found, it'll throw a 404 error, as it should.
  
  In your template, you can easily test for the entry's status:
  
  ```
  {% if not entry.enabled %}
      <p>Danger danger! I am disabled!</p>
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: That's awesome.  Works perfectly.  Thanks for the quick response.  
  > **username_1**: That's great! I added a little ting in my answer – it's probably a good idea to include `.section('yourSectionHandle')` in the `craft.entries` query, as entries belonging to different sections can have identical slugs.  
  
  ---
  
  