Advertisement
Digitalraindrops

latest-posts-fourteen-days.php

Aug 21st, 2011
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. <?php
  2.     $wp_query= null;
  3.     $wp_query = new WP_Query();
  4.     $args = array(
  5.         'post_type' => 'post',
  6.         'category_name' => 'featured',
  7.         'orderby' => 'comment_count',
  8.         'showposts' => '10',
  9.         '&paged' => $paged,
  10.     );
  11.    
  12.     // posts in the last two weeks
  13.     function jgl_filter_where( $where = '' ) {
  14.     $where .= " AND post_date > '" . date('Y-m-d', strtotime('-2 weeks')) . "'";
  15.     return $where;
  16.     }
  17.     add_filter( 'posts_where', 'jgl_filter_where' );
  18.     $wp_query->query( $args );
  19.     remove_filter( 'posts_where', 'jgl_filter_where' );
  20. ?>
  21.  
  22. <?php if ( $wp_query->have_posts() ) : ?>
  23.  
  24.     <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
  25.  
  26.         <li>
  27.             <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  28.             <span>
  29.             <a class="comments" href="<?php the_permalink(); ?>#comments"><?php echo $post->comment_count; ?> Comments</a>Posted Under: <?php the_category(', '); ?>
  30.             </span>
  31.         </li>
  32.  
  33.     <?php endwhile; ?>
  34. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement