Answers.Body: <p>Specify the locale when getting the drafts, or else it will fetch drafts for the default locale. In my case, there was only drafts for a particular locale but not the default.</p>
  
  <p><code>{% set drafts = craft.entryRevisions.getDraftsByEntryId(entry.id, 'localeId') %}
  </code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-17T17:57:26.917Z
Answers.LastActivityDate: 2017-11-17T17:57:26.917Z
Answers.UserDisplayName: Angelo
Body: <p>I'm trying to get the drafts for the entry on the front end to populate my plugin on the sidebar but cannot get the drafts returned with this code in a Twig template.</p>
  
  <p><code>entry</code> is an <code>EntryModel</code> here.</p>
  
  <pre><code>The entry ID is {{entry.id}} 
  
  
  {% set drafts = craft.entryRevisions.getDraftsByEntryId(entry.id) %}
  
  {{ dump(drafts) }}
  </code></pre>
  
  <p>drafts is an array of 0 elements</p>
  
  <p>Even trying it in a PHP plugin class and hard-coding the entry ID like </p>
  
  <pre><code>$drafts = craft()-&gt;entryRevisions-&gt;getDraftsByEntryId(995);
  </code></pre>
  
  <p><code>$drafts</code> is empty.</p>
  
  <p>Everywhere I've looked says to do like the above; however, this doesn't return any drafts that belong to the entry as expected.</p>
  
  <p>In the dropdown by the entry name, it has the 2 Drafts' names and when clicking them it takes me to the draft, so it seems like the drafts are correctly mapped to this entry. </p>
  
  <p>What am I missing?</p>
  
Tags: <control-panel><entry><frontend><draft>
Title: craft.entryRevisions.getDraftsByEntryId(entry.id) is returning an empty array
ThreadText: # craft.entryRevisions.getDraftsByEntryId(entry.id) is returning an empty array
  
  (Asked by: username_0 on 2017-11-17)
  
  I'm trying to get the drafts for the entry on the front end to populate my plugin on the sidebar but cannot get the drafts returned with this code in a Twig template.
  
  `entry` is an `EntryModel` here.
  
  ```
  The entry ID is {{entry.id}} 
  
  {% set drafts = craft.entryRevisions.getDraftsByEntryId(entry.id) %}
  
  {{ dump(drafts) }}
  
  ```
  
  drafts is an array of 0 elements
  
  Even trying it in a PHP plugin class and hard-coding the entry ID like
  
  ```
  $drafts = craft()->entryRevisions->getDraftsByEntryId(995);
  
  ```
  
  `$drafts` is empty.
  
  Everywhere I've looked says to do like the above; however, this doesn't return any drafts that belong to the entry as expected.
  
  In the dropdown by the entry name, it has the 2 Drafts' names and when clicking them it takes me to the draft, so it seems like the drafts are correctly mapped to this entry.
  
  What am I missing?
  
  **Tags:** control-panel, entry, frontend, draft
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-11-17. Score: 1 | Accepted answer
  
  Specify the locale when getting the drafts, or else it will fetch drafts for the default locale. In my case, there was only drafts for a particular locale but not the default.
  
  `{% set drafts = craft.entryRevisions.getDraftsByEntryId(entry.id, 'localeId') %}`
  
  
  ---
  
  