Discuss your project
Wordpress Backoffice

WordPress: Remove default elements in the header

In some cases, we need to remove all the default meta tags from WordPress templates. To do this, simply add the following code to your functions.php file remove_action('wp_head', 'wp_print_styles', 8); remove_action('wp_head', 'wp_print_head_scripts', 9); ...

WordPress: Remove default elements in the header



In some cases, we need to remove all the default meta tags from WordPress templates.
To do this, simply add the following code to your functions.php file

remove_action('wp_head', 'wp_print_styles', 8);
remove_action('wp_head', 'wp_print_head_scripts', 9);
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
remove_action('wp_head', 'wp_generator');
add_filter('show_admin_bar', '__return_false');

Reproduce this customization today

The principle of the hook remains useful, but the administration screens and WordPress APIs have evolved since the publication. Test the code in a staging environment with the exact version of the site's core, theme, and plugins.

  • Save the files and the database before making any changes.
  • Control user capabilities, nonces, input validation, and output escaping.
  • Place customizations in a dedicated plugin or a child theme to preserve updates.

Reference: official WordPress plugin development manual.

Share this article