Skip to content

Instantly share code, notes, and snippets.

@knolaust
Last active January 30, 2024 15:07
Show Gist options
  • Save knolaust/ef429bfc7748bddaccdbd025bf55546a to your computer and use it in GitHub Desktop.
Save knolaust/ef429bfc7748bddaccdbd025bf55546a to your computer and use it in GitHub Desktop.
Remove unecessary WordPress clutter from header.
<?php
/**
* Remove Unnecessary WordPress Header Clutter
*
* This code snippet removes unnecessary elements from the WordPress header to improve page load and security.
* Place this code in your theme's functions.php file.
*
* Gist Keywords: wordpress, security, performance
*
* @category Performance
* @author Knol Aust
* @version 1.0.0
* @description This code removes various WordPress header elements that are not required for most websites.
*/
/**
* Remove Unnecessary Header Elements
*/
function remove_header_clutter() {
// Remove Really Simple Discovery (RSD) link
remove_action('wp_head', 'rsd_link');
// Remove WordPress Generator meta tag
remove_action('wp_head', 'wp_generator');
// Remove Feed Links
remove_action('wp_head', 'feed_links', 2);
// Remove Index Rel Link
remove_action('wp_head', 'index_rel_link');
// Remove Windows Live Writer manifest link
remove_action('wp_head', 'wlwmanifest_link');
// Remove Feed Links Extra
remove_action('wp_head', 'feed_links_extra', 3);
// Remove Start Post Rel Link
remove_action('wp_head', 'start_post_rel_link', 10, 0);
// Remove Parent Post Rel Link
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
// Remove Adjacent Posts Rel Link
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
}
// Hook the function to execute
add_action('init', 'remove_header_clutter');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment