板邓:wordpress调用热门文章排行代码WP-PostViews

 

板邓网上找了很多文章,代码都很复杂,不适合新手使用,下面板邓分享最简单方式就可以实现热门文章调用:

1、安装插件 WP-PostViews,设置好。

 

 

调用代码如下:

<?
$args=array(
'numberposts'=>8,
'orderby'=>'meta_value_num',//按点击量排序
'meta_key'=>'views'
);
$rand_posts=get_posts($args);
foreach($rand_posts as $post){
setup_postdata($post);

?>

  <ul >
    <a href="<?php the_permalink(); ?>" title="<? the_title(); ?>"><?php the_title(); ?></a>
    <? echo the_views(true, '阅读(&nbsp;','&nbsp;)次','true');?>   </ul> <?}?>

 

posted @ 2016-06-18 23:40  贵隆  阅读(2753)  评论(0编辑  收藏  举报