具体效果可以看本站首页
后台开关代码部署
找到主题目录的options.php在最下面添加以下代码
/** 热门排行自定义后台设置 www.vlwx.com */ $options[] = array( 'name' => __('热门排行', 'haoui'), 'type' => 'heading'); $options[] = array( 'name' => __('首页热门排行', 'haoui'), 'id' => 'most_list_s', 'std' => true, 'desc' => __('开启', 'haoui'), 'type' => 'checkbox'); $options[] = array( 'name' => __('首页热门排行', 'haoui').$rrr.__('模式', 'haoui'), 'id' => 'most_list_style', 'std' => "comment", 'type' => "radio", 'options' => array( 'comment' => __('按文章评论数', 'haoui'), 'view' => __('按文章阅读数', 'haoui') )); $options[] = array( 'name' => __('首页热门排行', 'haoui').$rrr.__('标题', 'haoui'), 'id' => 'most_list_title', 'std' => __('一周热门排行', 'haoui'), 'type' => 'text'); $options[] = array( 'name' => __('首页热门排行', 'haoui').$rrr.__('最近多少天内的文章', 'haoui'), 'id' => 'most_list_date', 'std' => 7, 'class' => 'mini', 'type' => 'text'); $options[] = array( 'name' => __('首页热门排行', 'haoui').$rrr.__('显示数量', 'haoui'), 'id' => 'most_list_number', 'std' => 5, 'class' => 'mini', 'type' => 'text');
首页代码部署
找到主题根目录的index.php文件搜索ads_index_01,在上面添加
功能代码部署
在主题的modules目录新建一个文件,文件名为mo_recent_posts_most.php,文件内容为以下代码
get_results("SELECT comment_count, ID, post_title, post_date FROM $wpdb->posts WHERE post_date BETWEEN '$daysago' AND '$today' AND post_status='publish' AND post_type='post' ORDER BY comment_count DESC LIMIT 0 , $limit"); if(empty($result)) { $output = '
'.__('评论', 'haoui').' ('.$commentcount.')
'.$i.''.$title.''.__('阅读', 'haoui').' ('.$post_views.')
'.$i.'ID).'" title="'.$title.'">'.$title.'添加css样式代码
.mpc-bg {background:#FFF;padding:1px 20px;margin:10px 0px 15px 0px;} .label {position:relative;display:inline-block;padding:5px 7px;font-size:12px;line-height:14px;color:#ffffff;vertical-align:baseline;white-space:nowrap;background-color:#999;} .most-comment-posts ul{margin: 0 0 20px;padding: 20px 0 0;list-style: none;overflow: hidden;} .most-comment-posts li{font-size: 13px;white-space: nowrap; overflow: hidden; clear: both;text-overflow: ellipsis;} .most-comment-posts li > a span{color: #FF5E52;} .most-comment-posts p{float: right;font-size: 12px;color: #999;} .most-comment-posts .label{margin-right: 8px;padding: 2px 7px;top: -1px;} .label-1{background-color: #ff7878;} .label-2{background-color: #64CA38;} .label-3{background-color: #52BAF5;} .most-comment-posts .item-1 a {color:#ff7878} .most-comment-posts .item-2 a {color:#64CA38} .most-comment-posts .item-3 a {color:#52BAF5} .most-comment-posts a {color: #777;} .text-muted{color:#999} .most-comment-posts .item-1 a:hover,.most-comment-posts .item-2 a:hover,.most-comment-posts .item-3 a:hover {color:#FF5E52}
'._hui('most_list_title').'
'.$output.'