Promote your Service and Product online Contact us

+91 87 44 999667; +91 99 11 883996 info@3pixls.com, sales@3pixls.com

Display Your Most Popular Posts In the Last 30 Days Without a Plugin


1357250515What_s_Trending620x2251
[php]
<div class="col-md-12">
<div class="custom-heading02">
<h2>Trending Articles</h2>
</div><!– .custom-heading02 end –>
<?php
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(‘post_type=post&posts_per_page=10&orderby=comment_count&order=DESC’);

while (have_posts()): the_post(); ?>
<div class="col-md-6 col-sm-12">
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail( ‘medium’, array( ‘class’ => ‘img-responsive’ ) ); ?></a>
<span><strong><a href="<?php the_permalink() ?>"> <?php echo substr(the_title(”, ”, FALSE), 0, 50); ?></a></strong></span><br />
<span class="postdate"><?php the_time(‘F jS, Y’) ?> by <?php the_author_posts_link() ?></span>
</div>
<?php
endwhile;
wp_reset_query();
?>
</div>
[/php]

Just add this to your template where you want to use it. No plugins necessary!