Title: posts_where problem
Last modified: August 20, 2016

---

# posts_where problem

 *  [Cristiano](https://wordpress.org/support/users/iclapton/)
 * (@iclapton)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/posts_where-problem/)
 * Hi WP friends,
 * I have a taxonomy called “genero”. I´m trying to limit my “genero” archive page
   to just show future posts, like an event page.
 * So, I used this code:
 *     ```
       function filter_where( $where ) {
       	if(is_tax(genero)){
       		$where .= " AND post_date > '" . date('Y-m-d', strtotime('0 days')) . "'";
       	}
       	return $where;
       }
       add_filter( 'posts_where', 'filter_where' );
   
       function reset_filter_where() {
       	if(is_tax(genero)){
       		remove_filter( 'posts_where', 'filter_where' );
       	}
       }
       add_action('thematic_below_archiveloop','reset_filter_where');
       ```
   
 * It works great on the genero´s archive page, but it breaks all the other looping
   on other pages. I don´t know what is happening.
 * Any help?
    Thanks!

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

 *  Thread Starter [Cristiano](https://wordpress.org/support/users/iclapton/)
 * (@iclapton)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/posts_where-problem/#post-3171901)
 * Ah, I´m using the thematic framework and the second action is just to put that
   code after the archive loop, to reset the filter…
 *  [Rebecca O'Brien](https://wordpress.org/support/users/rjmastey/)
 * (@rjmastey)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/posts_where-problem/#post-3171904)
 * How does it “break” the other looping? Only displaying future posts?
 * You need to place double (or single, whichever floats your boat) about genero.
   Not sure if that will fix the problem, but it’s syntactically incorrect as is
   and can cause general wonkiness.
    `if(is_tax('genero')){`
 *  Thread Starter [Cristiano](https://wordpress.org/support/users/iclapton/)
 * (@iclapton)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/posts_where-problem/#post-3171907)
 * Hey Rebecca, thanks for your answer!
 * When I say it breaks I mean I get a blank page in another archive page, for exemple!
   On home, where I have another 2 loops, it shows the page, the header, but the
   loops are empty.
 * I tryed your solution, with the same result…
 *  [Rebecca O'Brien](https://wordpress.org/support/users/rjmastey/)
 * (@rjmastey)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/posts_where-problem/#post-3171927)
 * Can you provide a link?
 * If you want to this happen *all* the time in that tax, try
 *     ```
       function filter_where( $where ) {
           $where .= " AND post_date > '" . date('Y-m-d', strtotime('0 days')) . "'";
          return $where;
       }
       function reset_filter_where() {
          remove_filter( 'posts_where', 'filter_where' );
       }
       if(is_tax('genero')) {
         add_filter( 'posts_where', 'filter_where' );
         add_action('thematic_below_archiveloop','reset_filter_where');
       }
       ```
   
 * Basically check to see if we’re even dealing with the taxonomy _then_ registering
   the filters and actions.
 *  Thread Starter [Cristiano](https://wordpress.org/support/users/iclapton/)
 * (@iclapton)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/posts_where-problem/#post-3171929)
 * Rebbeca, I can´t let the loopings broken, because the web is working right now
   and it has lot of visitors… let me know if you are still there, and I change 
   it to you for some minutes! 🙂

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

The topic ‘posts_where problem’ is closed to new replies.

## Tags

 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 5 replies
 * 2 participants
 * Last reply from: [Cristiano](https://wordpress.org/support/users/iclapton/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/posts_where-problem/#post-3171929)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
