Title: Exclude posts by year
Last modified: August 19, 2016

---

# Exclude posts by year

 *  Resolved [chen](https://wordpress.org/support/users/chen/)
 * (@chen)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/exclude-posts-by-year/)
 * Hi,
 * does anyone know how to exclude old posts by year (ex. in 2004 and 2005) from
   displaying on the homepage?
 * Thank you.

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/exclude-posts-by-year/#post-1231820)
 * To exclude posts, using the WordPress Default theme for example, in the wp-content/
   themes/default/index.php file, just before the line:
    `<?php if (have_posts()):?
   >`
 * put this:
 *     ```
       <?php
         function filter_where($where = '') {
           //retrieve posts dated Jan 1, 2006 and newer
           $where .= " AND post_date >= '2006-01-01'";
           return $where;
         }
       add_filter('posts_where', 'filter_where');
       query_posts($query_string);
       ?>
       ```
   
 * The [query_posts() article](http://codex.wordpress.org/Template_Tags/query_posts)
   explains the arguments in detail.
 * Related:
    [Stepping Into Template Tags](http://codex.wordpress.org/Stepping_Into_Template_Tags)
   [Stepping Into Templates](http://codex.wordpress.org/Stepping_Into_Templates)
   [Template Hierarchy](http://codex.wordpress.org/Template_Hierarchy)
 *  Thread Starter [chen](https://wordpress.org/support/users/chen/)
 * (@chen)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/exclude-posts-by-year/#post-1231835)
 * Hi Michael,
 * thank you so much!!!! it works! 🙂
 * thanks again really..
 * more power!

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

The topic ‘Exclude posts by year’ is closed to new replies.

## Tags

 * [exclude](https://wordpress.org/support/topic-tag/exclude/)
 * [meh_code](https://wordpress.org/support/topic-tag/meh_code/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [chen](https://wordpress.org/support/users/chen/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/exclude-posts-by-year/#post-1231835)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
