WordPress页脚显示页面加载时间
修改主题的 functions.php 文件,合适位置插入以下代码
//显示页面查询次数、加载时间和内存占用
function performance( $visible = false ) {
$stat = sprintf( '本次加载耗时:%.3fs',
timer_stop( 0, 3 )
);
echo $visible ? $stat : "<!-- {$stat} -->" ;
}
在需要显示的地方,使用下面的代码进行调用
<?php if(function_exists('performance')) performance(true) ;?>
注:
performance true 页面中直接显示
performance false html源码中显示