建站教程

建站教程

Products

当前位置:首页 > 建站教程 >

解决wordpress出错:Warning: A non-numeric value encountered in…

GG网络技术分享 2025-03-18 16:04 0


解决Warning: A non-numeric value encountered in…警告的意思直译为“遇到的非数字值”,get_query_var('cpage')被视为了非数字值。那么现在添加intval把它转换为数字值即可。

按照提示,找到出错文件以及代码,

$cnt = count($comments);//获取主评论总数量

$page = get_query_var('cpage');//获取当前评论列表页码

$cpp=get_option('comments_per_page');//获取每页评论显示数量

if (ceil($cnt/$cpp) == 1 || ($page>1 && $page == ceil($cnt/$cpp))) {

$commentcount = $cnt + 1;//如果评论只有1页或者是最后一页,初始值为主评论总数

} else {

$commentcount = $cpp * $page + 1;

$page = get_query_var('cpage');

改为

$page = intval(get_query_var('cpage'));

或者将

$commentcount = $cpp * $page + 1;

改为

$commentcount = intval($cpp) * intval($page) + 1;

标签: WordPress 教程

提交需求或反馈

Demand feedback