Home >Backend Development >PHP Tutorial >Steps to Remove WP Version Number from WordPress Feed
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');In this way, you can start from the head of the website Remove the code containing the version number mentioned at the beginning of this article. Do you think it’s over here? nononono, do you think you have completely hidden the WordPress version number of your site? Open your feed source, such as http://site address/feed, and you will see something like the second piece of code at the beginning of this article. ? wordpress.org/?v=4.7.3
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 '';}Go here for the WordPress tutorial on removing the WP version number in the feed And the method is announced to have come to an end. If you haven't noticed the feed yet, you should look back now. Of course, if you find that the WordPress version number is leaked elsewhere, you are welcome to suggest it and let us study it together.
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!