Home> CMS Tutorial> WordPress> body text

How to remove WordPress version number using code

藏色散人
Release: 2021-02-25 16:24:55
forward
2687 people have browsed it

The following tutorial column ofWordPresswill introduce you to the code to remove the WordPress version number. I hope it will be helpful to friends in need!

How to remove WordPress version number using code

Code implementation to remove WordPress version number

By default, WordPress will output the version number in the header of the page. There are certain safety risks.

Add the following code in functions.php of the current theme to remove the WordPress version number in feed and js/css at the same time:

// 同时删除head和feed中的WP版本号 function ludou_remove_wp_version() { return ''; } add_filter('the_generator', 'ludou_remove_wp_version'); // 隐藏js/css附加的WP版本号 function ludou_remove_wp_version_strings( $src ) { global $wp_version; parse_str(parse_url($src, PHP_URL_QUERY), $query); if ( !empty($query['ver']) && $query['ver'] === $wp_version ) { // 用WP版本号 + 12.8来替代js/css附加的版本号 // 既隐藏了WordPress版本号,也不会影响缓存 // 建议把下面的 12.8 替换成其他数字,以免被别人猜出 $src = str_replace($wp_version, $wp_version + 12.8, $src); } return $src; } add_filter( 'script_loader_src', 'ludou_remove_wp_version_strings' ); add_filter( 'style_loader_src', 'ludou_remove_wp_version_strings' );
Copy after login

The above is the detailed content of How to remove WordPress version number using code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!