首页    >    新闻资讯    >   如何不用插件而在WordPress边栏中显示热门内容

如何不用插件而在WordPress边栏中显示热门内容

有一些插件可以实现这个功能,但如果你不想用插件的话,可以考虑下面的方法。

很简单,把以下代码粘贴到sidebar.php里去:

<h2>Popular Posts</h2>
<ul>
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
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>

大功告成!

原文:How to: Display your most popular content in your blog sidebar

分类:新闻资讯

标签:, ,

* 版权声明:作者WordPress啦! 转载请注明出处。

kadıköy escortbostancı escortataşehir escortbostancı escortmaltepe escortmaltepe escortanadolu yakası escortanadolu yakası escortataşehir escortbostancı escortistanbul escortkartal escortbostancı escortkartal escortkadıköy escortpendik escortpendik escortmaltepe escortataşehir escortmaltepe escortmaltepe escortanadolu yakası escortkadıköy escortataşehir escortkadıköy escortataşehir escortümraniye escortataşehir escortkartal escortescort bayankartal escortpendik escortkartal escortgöztepe escorttuzla escortkadıköy escortkartal escortkadıköy escortmaltepe escortkartal escortataşehir escortmaltepe escortbostancı escortkartal escortpendik escortkadıköy escortataköy escortavrupa yakası escortataköy escortbakırköy escortbeylikdüzü escorttaksim escorthalkalı escortetiler escortbodrum escortmalatya escortankara escortantalya escortmersin escortantalya escortHacklinkHacklinkshellwso shellwso shellgörüntülü sohbettipobetbahis siteleri