Title: This filter doesn&#039;t work
Last modified: August 20, 2016

---

# This filter doesn't work

 *  Resolved [alvarols](https://wordpress.org/support/users/alvarols/)
 * (@alvarols)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/this-filter-doesnt-work/)
 * I’m trying to use this code that I take from wordpress codex, but the filter 
   is not taking effect.
 * ` <?php
    function filter_where($where = ”) { //posts in the last 24 Hours $where.
   = ” AND post_date > ‘” . date(‘Y-m-d H:i:s’, strtotime(‘-36 hours’)) . “‘”; return
   $where; } add_filter(‘posts_where’, ‘filter_where’); $query = new WP_Query(“cat
   =”.$categoria.””); ?> <?php if(have_posts()) : ?><?php while($events_query->have_posts()):
   $postnum = $postnum + 1; $events_query->the_post(); ?> <h1 class=”negrocentro”
   >“><?php the_title(); ?></h1> <?php endwhile; ?> <?php endif; ?> <?php remove_filter(‘
   posts_where’, ‘filter_where’ ); ?>

Viewing 1 replies (of 1 total)

 *  Thread Starter [alvarols](https://wordpress.org/support/users/alvarols/)
 * (@alvarols)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/this-filter-doesnt-work/#post-3385413)
 * Solved:
 * `<?php
                                function filter_where($where = ”) {      //
   posts in the last 24 Hours                             $where .= ” AND post_date
   > ‘” . date(‘Y-m-d H:i:s’, strtotime(‘-36 hours’)) . “‘”;                    
   return $where;                           }                             add_filter(‘
   posts_where’, ‘filter_where’);                             $query = new WP_Query(“
   cat=”.$categoria.””);                         ?>                         <?php
   if(have_posts()) : ?><?php while($events_query->have_posts()) : $postnum = $postnum
   + 1; $events_query->the_post(); ?>                         <h1 class=”negrocentro”
   >“><?php the_title(); ?></h1>                         <?php endwhile; ?>     
   <?php endif; ?>                         <?php                             remove_filter(‘
   posts_where’, ‘filter_where’ );                         ?>

Viewing 1 replies (of 1 total)

The topic ‘This filter doesn't work’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [alvarols](https://wordpress.org/support/users/alvarols/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/this-filter-doesnt-work/#post-3385413)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
