SHARE
TWEET

Untitled

a guest Oct 10th, 2011 129 Never
  1. //FUNCTION TO LIMIT SEARCH TO LAST 30 DAYS
  2. <?php function filter_where( $where = '' ) {
  3.         $where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
  4.         return $where;
  5. }
  6. add_filter( 'posts_where', 'filter_where' ); ?>
  7.  
  8. //THE QUERY AND LOOP
  9. <?php
  10. $query = new WP_Query( array( 'category__not_in' => array( '3', '8', '15' ) ) );
  11. if ( have_posts() ) : ?>
  12.         <?php while ( $query->have_posts()) : $query->the_post(); ?>
  13.                 <h3 class="entry-title"><?php the_title(); ?></h3>
  14.                 <?php the_content(); ?>
  15.                 <hr>           
  16.         <?php endwhile; ?>     
  17. <?php endif; ?>
  18. <?php wp_reset_postdata(); ?>
  19.  
  20.  
  21. //REMOVE FILTER THAT LIMITS SEARCH TO LAST 30 DAYS
  22. <?php remove_filter( 'posts_where', 'filter_where' ); ?>
  23.  
RAW Paste Data
Top