WordPress.org

Ready to get started?Download WordPress

Forums

How can I achive this? (2 posts)

  1. Minare
    Member
    Posted 4 years ago #

    I use this code combination in order to show most commented 5 posts af all time.

    I use latest wordpress version.

    But I want to make it a little different.

    How can I show most commented ( or most viewed ) posts of the recent ( last ) week ?

    I have Post-Plugin Library installed.

    This is what I use now:

    <div class="top">
    
    					<span class="heading1"><span>Populer Posts</span></span>
    
    					<ul>
    
    					<?php
    
    						$sql = "
    
    							SELECT *
    
    							FROM $wpdb->posts
    
    							WHERE 	post_date_gmt > ".(time()-strtotime('-2 weeks'))." AND post_type = 'post'
    
    							ORDER BY comment_count DESC LIMIT 5
    
    						";
    
    						$top_posts = $wpdb->get_results($sql);
    
    						foreach ($top_posts as $post)  {
    
    							?>
    
    							<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><span><a class="comments" href="<?php the_permalink(); ?>#comment"><?php echo $post->comment_count; ?> Yorum</a>Kategori: <?php the_category(', '); ?></span></li>
    
    							<?
    
    						}
    
    					?>
    
    					</ul>
    
    				</div>
    
    				<div class="clear"></div>
    
    			</div>
  2. Minare
    Member
    Posted 4 years ago #

    I feel so foolish not to have recognized it.

    when -2 weeks is replaced by -1 week

    will it work?

Topic Closed

This topic has been closed to new replies.

About this Topic