- 安装此插件: https://wordpress.org/plugins/autoptimize/
- 在其选项中启用wp-admin / options-general.php?page = autoptimize'优化HTML代码?'
- 在当前wp主题的文件functions.php中,应用下一个代码123456789101112131415161718add_filter('autoptimize_html_after_minify', function($content) {$site_url = 'https://bulk-editor.com/';$content = str_replace("", ' ', $content);$content = str_replace('', ' ', $content);$content = str_replace(" ", ' ', $content);$content = str_replace(' ', ' ', $content);$content = str_replace($site_url . '/wp-includes/js', '/wp-includes/js', $content);$content = str_replace($site_url . '/wp-content/cache/autoptimize', '/wp-content/cache/autoptimize', $content);$content = str_replace($site_url . '/wp-content/themes/', '/wp-content/themes/', $content);$content = str_replace($site_url . '/wp-content/uploads/', '/wp-content/uploads/', $content);$content = str_replace($site_url . '/wp-content/plugins/', '/wp-content/plugins/', $content);return $content;}, 10, 1);
- 不要忘记在$ site_url更改到您的站点链接的链接时,请在其末尾不加斜杠