WordPress的热门文章代码

本文链接: 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>

热门文章

Both comments and pings are currently closed.

One Response to “Chrome OS 平板电脑将威胁iPad的十大理由”

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


Search, Register and Transfer Web Domain Names and More - GoGoDNS.COM | Domain Names | Web Hosting | SSL Certificates | Email Accounts | Marketing Tools | Build a Website | Reseller Plans