Title: &#8220;get_posts&#8221; with date and comments?
Last modified: February 7, 2017

---

# “get_posts” with date and comments?

 *  [avtmx](https://wordpress.org/support/users/avtmx/)
 * (@avtmx)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/get_posts-with-date-and-comments/)
 * First, the post date does not display.
    Second, the comments part comes up with
   a huge MySQL error. In my code I’m using this…. ` <div id="rightpost"><br> <?
   php $posts = get_posts('numberposts=3&offset=0'); foreach ($posts as $post) :?
   > <h3>["><?php the_title() ?>](https://wordpress.org/support/topic/get_posts-with-date-and-comments/"<?php)
   </h3> <div class="storycontent"> <?php the_excerpt() ?> </div> <div class="feedback"
   > <?php the_date() ?> |  <?php wp_link_pages(); ?> <?php comments_popup_link(
   __('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?> </div> <br> <?
   php endforeach; ?> </div> ' This is the error...  ‘Database error: [You have 
   an error in your SQL syntax. Check the manual that corresponds to your MySQL 
   server version for the right syntax to use near ‘AND comment_approved = ‘1” at
   line 1] SELECT COUNT(comment_ID) FROM wp_comments WHERE comment_post_ID = AND
   comment_approved = ‘1’; Database error: [You have an error in your SQL syntax.
   Check the manual that corresponds to your MySQL server version for the right 
   syntax to use near ‘AND comment_approved = ‘1” at line 1] SELECT COUNT(*) FROM
   wp_comments WHERE comment_post_ID = AND comment_approved = ‘1’ \` Any ideas on
   what i should change the code to?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/get_posts-with-date-and-comments/#post-93637)
 * why don’t you continue where you started it initially?
    [http://wordpress.org/support/5/13299](http://wordpress.org/support/5/13299)
 *  [Mike](https://wordpress.org/support/users/mike/)
 * (@mike)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/get_posts-with-date-and-comments/#post-93638)
 * [Magpie!](http://magpierss.sourceforge.net/)
 *  Thread Starter [avtmx](https://wordpress.org/support/users/avtmx/)
 * (@avtmx)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/get_posts-with-date-and-comments/#post-93650)
 * A simple…
    ‘ : start_wp(); ?>’ would do. 🙂 Thanks, those threads really helped
   me out.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘“get_posts” with date and comments?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [avtmx](https://wordpress.org/support/users/avtmx/)
 * Last activity: [21 years, 7 months ago](https://wordpress.org/support/topic/get_posts-with-date-and-comments/#post-93650)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
