Aus crazylinux.de
Zur Navigation springen Zur Suche springen

Remove WP Generator Meta Tag

It can be considered a security risk to make your wordpress version visible and public you should hide it.

Put in functions.php file in your theme:

remove_action('wp_head', 'wp_generator');


How to remove author sitemaps from WordPress

In the WordPress 5.5 release they have added the ability to generate a XML sitemap. XML sitemap are great because it tell search engines such as Google and Bing what pages to crawl. One of the sitemap which the WordPress core creates is a user sitemap. On a WordPress site I work on we didn’t want to use this feature, so I’m going to go through the process how to disable the sitemap.

placing the following code below into your functions.php

function remove_author_category_pages_from_sitemap($provider, $name)
    if ('users' === $name) {
        return false;
    return $provider;

add_filter('wp_sitemaps_add_provider', 'remove_author_category_pages_from_sitemap', 10, 2);

What the code does is creates a function called remove_author_category_pages_from_sitemap with two arguments $provider and $name. If the name of the sitemap is users the function return false. Otherwise if it’s not a user sitemap it will build the xml file as usual.

We then create a add_filter hook on wp_sitemaps_add_provider then add the function we just created. Finally we give the sitemap a priority of 10 and tell the hook to accept 2 arguments.

As you can see from the code above it’s very easy to remove user sitemaps from your WordPress site.