本文最后更新于2021年4月1日,已超过 4 年没有更新,如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!
使用懿古今大佬的NANA主题也有一段时间了,在使用过程中,发现NANA主题存在着一些bug,今天我就针对自己发现的bug进行的修复,做一下说明。
1、站长推荐
之前写过,今天就不再赘述了,请看下面的文章。
2、热评文章
修改前,表现为杂乱显示,且自动补充到8篇,不论文章是否有评论。
修改后,按照天数自动对有评论的文章进行排序。
只需要将主题下inc/functions下的hot-comment.php中的第5-11行代码
$limit_date = current_time('timestamp') - ($days*26400);
if($limit_date < 0){
$limit_date=0;
}
$limit_date = date("Y-m-d H:i:s",$limit_date);
$sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND post_date < '".current_time('mysql')."' AND post_date > '".$limit_date."' ORDER BY comment_count DESC LIMIT 0 , $number ";
</pre>
改为
<pre lang="php" line="1" escaped="true">
$today = date("Y-m-d H:i:s"); //获取今天日期时间
$daysago = date( "Y-m-d H:i:s", strtotime($today) - ($days * 24 * 60 * 60) ); //Today - $days
$sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND post_date < '$today' AND post_date > '$daysago' AND post_password = '' ORDER BY comment_count DESC LIMIT 0 , $number ";
3、热门文章
修改前,显示如下图,指定期限天数无效。
修改后,如下图,在后台设置期限,可以正常显示。
只需要将主题下inc/functions下的hot-post.php中的第5-14行代码
$limit_date = current_time('timestamp') - ($days*26400);
$limit_date = date("Y-m-d H:i:s",$limit_date);
$where = '';
$temp = '';
if(!empty($mode) && $mode != 'both') {
$where = "post_type = '$mode'";
}
else {
$where = '1=1';
}
$most_viewed = $wpdb->get_results("SELECT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND post_date > '".$limit_date."' AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit");
改为
$today = date("Y-m-d H:i:s"); //获取今天日期时间
$daysago = date( "Y-m-d H:i:s", strtotime($today) - ($days * 24 * 60 * 60) ); //Today - $days
$where = '';
$temp = '';
if(!empty($mode) && $mode != 'both') {
where = "post_type = '$mode'";
}
else {
$where = '1=1';
}
$most_viewed = $wpdb->get_results("SELECT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE post_date < '$today' AND post_date > '$daysago' AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit");
目前就发现了上面3个小bug,后续发现在进行补充!
最新评论