Bloggers who use WordPress are generally very security-conscious, that is, removing the WordPress version number to prevent people with bad intentions from using the vulnerabilities of the old version to attack the website. (Free worpress template download)
WordPress will add the following code to the front-end code head:
<meta name="generator" content="WordPress 4.7.3" />
After the usage method is removed, there will still be one in the WordPress feed:
<generator>https://wordpress.org/?v=4.7.3</generator>
The above 4.7.3 is the version number of WordPress. In fact, there are many methods on the Internet to remove the version number information added by WordPress. , then today PHP Chinese Network needs to share an almost perfect solution. First, let’s take a look at several common methods:
Method 1: Directly delete wp_head()# in header.php
##Generally, wp_head() is used in theme file header.php developed in accordance with WordPress specificationsBut they just didn’t think about it. Many plug-ins/themes will perform some operations through this function. Deleting this function will make these plug-ins/themes unable to work. Of course, if you are a friend who pursues the ultimate or is willing to toss things around, this is not a bad idea.Method 2: remove_action
WordPress has a very good developmentremove_action('wp_head', 'wp_generator');
So how to remove the WordPress version number in the feed?
The method that remains unchanged for thousands of years is to add the following code to the current theme functions.php file:// 同时删除head和feed中的WP版本号 add_filter('the_generator', 'fanly_remove_wp_version'); function fanly_remove_wp_version() { return '';}
The above is the detailed content of Steps to Remove WP Version Number from WordPress Feed. For more information, please follow other related articles on the PHP Chinese website!