Advertisement
alchymyth

Untitled

Apr 17th, 2011
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2.   function filter_where( $where = '' ) {
  3.     // posts in the last 30 days
  4.     $where .= " AND post_date > '" . date('Y-m-d', strtotime('-2 days')) . "'";
  5.     return $where;
  6. }
  7. add_filter( 'posts_where', 'filter_where' );
  8.  
  9. $my_query = new WP_Query( 'posts_per_page=2' ); //add some query parameter
  10. if($my_query->have_posts()) :
  11. while($my_query->have_posts()) :
  12. $my_query->the_post();
  13. the_title();
  14. // and whatever you want to output
  15. endwhile;
  16. else : echo 'no post found';
  17. endif;
  18.  
  19. remove_filter('posts_where', 'filter_where');
  20. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement