本文链接: http://sancc.us/wordpress/posts/4824
在需要显示热门文章的地方插入下列代码即可:
<p>热门文章</p>
<ul>
<?php $result = $wpdb->get_results(“SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 10″);
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href=”<?php echo get_permalink($postid); ?>” title=”<?php echo $title ?>”>
<?php echo $title ?></a> (<?php echo $commentcount ?>)</li>
<?php } } ?>
</ul>
RSS Feed



Posted in
Tags: 



[...] More: Chrome OS 平板电脑将威胁iPad的十大理由« 沙浪网 [...]