Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function filter_where( $where = '' ) {
- // posts in the last 30 days
- $where .= " AND post_date > '" . date('Y-m-d', strtotime('-2 days')) . "'";
- return $where;
- }
- add_filter( 'posts_where', 'filter_where' );
- $my_query = new WP_Query( 'posts_per_page=-1' ); //if you need, add some query parameter
- if($my_query->have_posts()) :
- while($my_query->have_posts()) :
- $my_query->the_post();
- the_title();
- // and whatever you want to output
- endwhile;
- else : echo 'no post found';
- endif;
- remove_filter('posts_where', 'filter_where');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement