Only return posts from last 30 days.
-
Hi,
I hope someone might be able to help me.
I am on 2.9.2 and thematic child theme
I am trying to filter the main loop, and category loop and search results to only return posts from the last 30 days.
I think I am close to solving the main loop and category loop issue but it is not working
I have the following code in my functions.php
// Filter Index Loop function remove_thematic_index_loop() { remove_action ('thematic_indexloop','thematic_index_loop'); } add_action('init','remove_thematic_index_loop'); function my_index_loop() { //based on Austin Matzko's code from wp-hackers email list function filter_where($where = '') { //posts in the last 30 days $where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'"; return $where; } add_filter('posts_where', 'filter_where'); query_posts($query_string); while (have_posts()) : the_post(); ?> <div id="post-<?php the_ID(); ?>" class="<?php thematic_post_class(); ?>"> <?php thematic_postheader(); ?> <div class="entry-content"> <?php thematic_content(); ?> </div> <?php thematic_postfooter(); ?> </div><!-- .post --> <?php endwhile; } add_action('thematic_indexloop', 'my_index_loop');
Does anyone know where I am going wrong here? I tried replacing Austins filter with
query_posts('posts_per_page=2');
and this worked.Thanks
BAC
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Only return posts from last 30 days.’ is closed to new replies.