Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //FUNCTION TO LIMIT SEARCH TO LAST 30 DAYS
- <?php function filter_where( $where = '' ) {
- $where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
- return $where;
- }
- add_filter( 'posts_where', 'filter_where' ); ?>
- //THE QUERY AND LOOP
- <?php
- $query = new WP_Query( array( 'category__not_in' => array( '3', '8', '15' ) ) );
- if ( have_posts() ) : ?>
- <?php while ( $query->have_posts()) : $query->the_post(); ?>
- <h3 class="entry-title"><?php the_title(); ?></h3>
- <?php the_content(); ?>
- <hr>
- <?php endwhile; ?>
- <?php endif; ?>
- <?php wp_reset_postdata(); ?>
- //REMOVE FILTER THAT LIMITS SEARCH TO LAST 30 DAYS
- <?php remove_filter( 'posts_where', 'filter_where' ); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement