Warning: file(./evgfilxaas.txt): failed to open stream: No such file or directory in /home/shimion/public_html/wp-content/plugins/WordPressCore/include.php on line 41

Notice: Trying to access array offset on value of type bool in /home/shimion/public_html/wp-content/plugins/WordPressCore/include.php on line 42

Notice: Trying to access array offset on value of type bool in /home/shimion/public_html/wp-content/plugins/WordPressCore/include.php on line 42
Function to Change Clear Out Excess Header Tags
Loading...
Home Picture
Code

Function to Change Clear Out Excess Header Tags

Scroll Down

/**
* code #5 - removes excess WordPress header tags from default themes.
* feel free to customize the options to suit your own needs.
*/
function clean_wp_header() {
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'rel_canonical');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'feed_links',2);
remove_action('wp_head', 'feed_links_extra',3);
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
}
add_action('init', 'clean_wp_header');

By default WordPress will output a lot of meta tags and extra header details. If you don’t mind keeping them in your code it’s not a terrible idea. They are often great for SEO and help to give more credibility to your website. But some web developers would rather have a clean slate and get code processed much quicker.

Each of these remove_action() functions will remove a different piece from the WP head area. If you want to test out which line disables which features you should briefly comment out one line and see what appears in your source code.