0

I don't know when or why but this tags are inserted on my wordpress head automatically and they are adding style that disturb my layout:

<meta name="generator" content="WordPress 4.2.2">

<style type="text/css" media="screen">
    html { margin-top: 32px !important; }
    * html body { margin-top: 32px !important; }
    @media screen and ( max-width: 782px ) {
        html { margin-top: 46px !important; }
        * html body { margin-top: 46px !important; }
    }
</style>

How can I remove it? It is annoying! Actually the generator is the minor of my problems. Look at all the things that are there: enter image description here

The reason why I added wp-head on the first place was because I wanted to use a SEO plugin, but this gets inyected even without that plugin enabled.

  • 1
    Search the site. I am sure this has been answered. – s_ha_dum Jul 10 '15 at 19:17
  • yes, but how to write the question? I did search but didn't find what I wanted. This seems to be a new issue, I didn't experience it a year ago – Vandervals Jul 10 '15 at 19:22
  • Does this still happen if you disable all plugins and use the default theme? – czerspalace Jul 10 '15 at 19:43
  • happens without the plugins, the default theme I don't know I just added the wp head with an include on my <head> tag. There is nothing strange... – Vandervals Jul 10 '15 at 19:45
  • see this answer. – Milo Jul 11 '15 at 6:10
1

I believe a filter on the_generator will do it.

add_filter( 
  'the_generator', 
  '__return_empty_string',
  PHP_INT_MAX
);

Reference:
https://codex.wordpress.org/Function_Reference/_return_empty_string. https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/general-template.php#L2956

  • this removed the generator but I want to know how to remove every undesired tags and, if possible, how did those get there, – Vandervals Jul 10 '15 at 19:49
  • 1
    The idea is the same. Find the hook and callback and either remove the callback or return an empty string. Some are added by Core, others by themes or plugins. You have to do that research yourself. Find a utility similar to grep and have fun. – s_ha_dum Jul 10 '15 at 19:57
1

Most of what you want to remove is added in wp-includes/default-filters.php. Look in that file to see where they are added. The two that are adding css and js are the emoji support scripts:

add_action( 'wp_head', 'print_emoji_detection_script', 7 );
add_action( 'wp_print_styles', 'print_emoji_styles' );

To remove them, use the following in addition to the code which removes all the other bits like in this answer:

remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );

The other bits are for the admin toolbar when you're logged in. You can remove those by just unchecking admin toolbar in your user profile, or you can remove it entirely with:

add_filter( 'show_admin_bar', '__return_false' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.