This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 10th, 2011  |  syntax: None  |  size: 0.70 KB  |  views: 120  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.  
clone this paste RAW Paste Data