WordPress实现缩略图显示上月最多评论贴,这段代码可以显示上一个月评论最多的日志,属于一段计数型代码,把第一段放在functions.php中,然后再把第二段放在你想显示的文件中。 function most_wps_popular_thumbnail(){ $current_month = date('n'); if($current_month==1){ $last_month=12; }else{ $last_month=$current_month-1; } $args = array( 'posts_per_page' => 4, 'monthnum' => $last_month, 'orderby' => 'comment_count', ); ?> <h1>Most popular snippets</h1> <?php query_posts($args); ?> <?php while (have_posts()) : the_post(); ?> <a href="<?php the_permalink(); ?>" title="<? the_title(); ?>"><?php the_post_thumbnail( 'thumbnail' ); ?></a> <? endwhile; ?> <? wp_reset_query(); } 第二段 <? most_wps_popular_thumbnail(); ?> (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|