Title: Highlight new posts
Last modified: August 19, 2016

---

# Highlight new posts

 *  [jmmo20](https://wordpress.org/support/users/jmmo20/)
 * (@jmmo20)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/highlight-new-posts-1/)
 * Hello, I would like to highlight new/recent posts using a CSS class.
    So, say,
   posts in the last 7 days show a class “recentpost” and therefore look differently
   when listed together with older posts.
 * Can you help me do this?
    Thanks!

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

 *  [eelay](https://wordpress.org/support/users/eelay/)
 * (@eelay)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/highlight-new-posts-1/#post-746028)
 * hello.
    This code will add a css class recentpost if the post is newer than 7
   days;
 *     ```
       <div class="post <?php
       $prevWeek = time() - (7 * 24 * 60 * 60);
       $postDate = the_date('U', '', '', FALSE);
       if($postDate >= $prevWeek) {
       	echo"recentpost";
       	}
       ?>">your post</div>
       ```
   
 *  Thread Starter [jmmo20](https://wordpress.org/support/users/jmmo20/)
 * (@jmmo20)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/highlight-new-posts-1/#post-746123)
 * that’s fantastic!! Thank you so so so much!!! :o)
 *  [eelay](https://wordpress.org/support/users/eelay/)
 * (@eelay)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/highlight-new-posts-1/#post-746164)
 * No problem 😉

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

The topic ‘Highlight new posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [eelay](https://wordpress.org/support/users/eelay/)
 * Last activity: [18 years, 1 month ago](https://wordpress.org/support/topic/highlight-new-posts-1/#post-746164)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
