Advertisement
Digitalraindrops

Custom Post Date Filtered

Mar 14th, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function dr_filter_where( $where = '') {
  3.     $days = 28;
  4.     $where .= " AND post_date > '" . date('Y-m-d', strtotime('-' .$days .' days')) . "'";
  5.     return $where;
  6. }
  7. add_filter( 'posts_where', 'dr_filter_where' );
  8.  
  9. $args = array('post_type' => 'agenda', 'post_status' => 'publish', 'paged' => $paged );
  10. $wp_query= null;
  11. $wp_query = new WP_Query();
  12. $wp_query->query( $args );
  13. remove_filter( 'posts_where', 'dr_filter_where' );
  14. // Output our Query
  15. if ( $wp_query->have_posts() ) :
  16.     while ( $wp_query->have_posts() ) :
  17.     ?>
  18.    
  19.     <?php
  20.     endwhile;
  21. endif;
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement