Title: comments auto refresh
Last modified: August 20, 2016

---

# comments auto refresh

 *  [s0206](https://wordpress.org/support/users/s0206/)
 * (@s0206)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/comments-auto-refresh/)
 * Hello All
 * I have been trying to auto refresh the comments section on a new site I am developing.
   I came this excellent piece of code and it does the job brilliantly. The only
   thing is, it appears to display all comments from the entire blog rather the 
   comments for the specific post.
 * I can’t seem to work out what is wrong, here is the code:
 * [http://pastebin.com/jy30qmnW](http://pastebin.com/jy30qmnW)
 * It’s taken from the wonderful blog: [http://nikos-web-development.netai.net](http://nikos-web-development.netai.net)
 * Can anyone help me work out what is wrong here?
 * Thanks in advance

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

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/comments-auto-refresh/#post-3201798)
 * The database query ($request) is not restricting the search for comments with
   a particular post ID. You need to get the current post ID into the function somehow,
   then add something like `AND comment_post_ID = '$current_postID'` to the WHERE
   line.
 *  [foo123](https://wordpress.org/support/users/foo123/)
 * (@foo123)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/comments-auto-refresh/#post-3201852)
 * Hi s0206,
 * where exactly do you use this code?
    It makes a difference if the code can access
   the global $post variable (which contains the curent post_id) or is used outside
   the Loop.
 * If you can post the whole page where this code is used it could help resolve 
   this issue

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

The topic ‘comments auto refresh’ is closed to new replies.

## Tags

 * [ajax](https://wordpress.org/support/topic-tag/ajax/)
 * [Comments](https://wordpress.org/support/topic-tag/comments/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 3 participants
 * Last reply from: [foo123](https://wordpress.org/support/users/foo123/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/comments-auto-refresh/#post-3201852)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
