Answers.Body: <pre><code>{% set entries = craft.entries.orderBy('foo').all() %}
  </code></pre>
  
  <p>There is an <code>orderBy</code> property you can use on the query </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-28T05:18:12.463Z
Answers.LastActivityDate: 2018-06-28T05:18:12.463Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I want to order my search results by the post date (not the created on date).  And, this did not work...</p>
  
  <pre><code>{% if entries|length %}
      {% for post in entries.groupBy('postDate') %}
          {% include 'partials/card-standard-4' %}
      {% endfor %}                            
  {% else %}
      &lt;p&gt;Your search for “{{ query }}” didn’t return any results.&lt;/p&gt;
  {% endif %}
  </code></pre>
  
Tags: <templating>
Title: How can I order search results by the post date?
ThreadText: # How can I order search results by the post date?
  
  (Asked by: username_0 on 2018-06-27)
  
  I want to order my search results by the post date (not the created on date). And, this did not work...
  
  ```
  {% if entries|length %}
      {% for post in entries.groupBy('postDate') %}
          {% include 'partials/card-standard-4' %}
      {% endfor %}                            
  {% else %}
      <p>Your search for “{{ query }}” didn’t return any results.</p>
  {% endif %}
  
  ```
  
  **Tags:** templating
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-06-28. Score: 1 | Accepted answer
  
  ```
  {% set entries = craft.entries.orderBy('foo').all() %}
  
  ```
  
  There is an `orderBy` property you can use on the query
  
  
  ---
  
  