Advertisement
salmancreation

Display Your Most Popular Posts In the Last 30 Days Without

Jan 8th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. Display Your Most Popular Posts In the Last 30 Days Without a Plugin
  2.  
  3. <ul>
  4. <?php
  5. function filter_where($where = '') {
  6.     //posts in the last 30 days
  7.     $where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
  8.     return $where;
  9. }
  10. add_filter('posts_where', 'filter_where');
  11.  
  12. query_posts('post_type=post&posts_per_page=10&orderby=comment_count&order=DESC');
  13.  
  14. while (have_posts()): the_post(); ?>
  15.  
  16. <li><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li>
  17.  
  18. <?php
  19. endwhile;
  20. wp_reset_query();
  21. ?>
  22. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement