Home > Backend Development > PHP Tutorial > Steps to Remove WP Version Number from WordPress Feed

Steps to Remove WP Version Number from WordPress Feed

PHPz
Release: 2023-03-06 14:50:02
Original
1658 people have browsed it

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)

Steps to Remove WP Version Number from WordPress Feed

WordPress will add the following code to the front-end code head:

 <meta name="generator" content="WordPress 4.7.3" />
Copy after login

After the usage method is removed, there will still be one in the WordPress feed:

<generator>https://wordpress.org/?v=4.7.3</generator>
Copy after login

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 specifications

Function. The code at the beginning of this article is output through the wp_head() function. And this function will output some useless code, so some people just have fun and delete the wp_head() function directly.

But 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 development

interface, almost all WordPress functions can be added and deleted using similar methods , this is also a solution provided by most tutorials. Here Zifan just picks it up and adds the following code to the functions.php of the current theme:

   remove_action(&#39;wp_head&#39;, &#39;wp_generator&#39;);
Copy after login

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(&#39;the_generator&#39;, &#39;fanly_remove_wp_version&#39;);
function fanly_remove_wp_version() { return &#39;&#39;;}
Copy after login
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!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template