title: WordPress get_results order by post date
body: <p>I'm using "get_results" in WordPress for the first time and need to order the results by date. What I've got so far is:</p>
  
  <pre><code>$wpdb-&gt;get_results( "SELECT * FROM asi_posts WHERE post_type = 'post' AND post_status = 'publish' AND YEAR(post_date) = '" . $year-&gt;year . "'" );
  </code></pre>
  
  <p>This works fine in retrieving the posts, although it displays them with the oldest at the top of the list, instead of the most recent.</p>
  
  <p>What's the correct syntax that I should be using in that query to reverse the order?</p>
  
  <p>Thanks.</p>
  
  <p>In case it's more useful, here's the full code:</p>
  
  <pre><code>&lt;?php
                  // Get years that have posts
                  $years = $wpdb-&gt;get_results( "SELECT YEAR(post_date) AS year FROM asi_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY year DESC" );
  
                  //  For each year, do the following
                  foreach ( $years as $year ) {
  
                      // Get all posts for the year
                      $posts_this_year = $wpdb-&gt;get_results( "SELECT * FROM asi_posts WHERE post_type = 'post' AND post_status = 'publish' AND YEAR(post_date) = '" . $year-&gt;year . "'" );
  
                      // Display the year as a header
                      echo '&lt;div class="year-header-block"&gt;';
                      echo '&lt;button class="btn-year-reveal"&gt;View&lt;/button&gt;';
                      echo '&lt;h3&gt;' . $year-&gt;year . ' Industry News &amp;amp; Comment&lt;/h3&gt;';
                      echo '&lt;/div&gt;';
  
                      // Start an unorder list
                      echo '&lt;ul class="no-list yearly-archive-list"&gt;';
  
                      // For each post for that year, do the following
                      foreach ( $posts_this_year as $post ) {
                          // Display the title as a hyperlinked list item
                          echo '&lt;li&gt;&lt;a href="' . get_permalink($post-&gt;ID) . '"&gt;&lt;span class="news-title"&gt;' . $post-&gt;post_title . '&lt;/span&gt;&lt;span class="news-date"&gt;' . get_the_time('F j, Y', $post-&gt;ID) . '&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;';
                      }
  
                      // End the unordered list
                      echo '&lt;/ul&gt;';
                  }
              ?&gt;
  </code></pre>