0

I know that wp_head() is important, but using it injects so much crap into the header. I'd like to get it out and just add manually the 2-3 line of code that I need.

But, there is certain code added by WordPress that I want to keep:

<meta name="description" content="" />
<meta name="keywords" content="" />
<link rel='canonical' href='http://jlecologia.com/cms/' />
...
<meta http-equiv="Content-Language" content="fr-FR" />

How can this be generated for me? (Something like bloginfo('name') will be fine for me.)

3
  • 1
    andre You might get more targeted answers if you explain what's in the header that you don't want and what's missing that you do want. Right now it sounds like all you want are the <meta> and <link> elements above ... which is why @Wyck suggested the code to remove everything else.
    – EAMann
    Commented Mar 17, 2011 at 15:35
  • You also might get better answers if you didn't come off as being so angry and if you revised your title to something that didn't show your general ignorance of the utility you're lambasting. Commented Mar 17, 2011 at 15:54
  • I follow your GREAT advices, and tremendous wisdom by including it, and removing stuff i dont need with remove_action... I will be less an asshole next time choosing wording more carefully, who live, learn !, thanks !
    – menardmam
    Commented Mar 17, 2011 at 16:18

2 Answers 2

6

You can remove some of the header stuff with the following.

// remove unncessary header info
function remove_header_info() {
    remove_action('wp_head', 'rsd_link');
    remove_action('wp_head', 'wlwmanifest_link');
    remove_action('wp_head', 'wp_generator');
    remove_action('wp_head', 'start_post_rel_link');
    remove_action('wp_head', 'index_rel_link');
    remove_action('wp_head', 'adjacent_posts_rel_link');
}
add_action('init', 'remove_header_info');

The default installation does not include stuff like meta keywords, so that is either a theme or plugin that you are using.

3
  • not my question, but will check it out...
    – menardmam
    Commented Mar 17, 2011 at 15:27
  • 3
    @marc This is an incomplete answer to your question. The real answer is: don't remove wp_head(). Wyck's suggestion will stop wp_head from inserting what you don't want without ruining your site's compatibility with virtually every javascript-based plugin in the repository. Commented Mar 17, 2011 at 15:52
  • adding the action to init did not work for me; after_setup_theme works. (functions.php)
    – Aziz
    Commented May 5, 2016 at 13:25
0

Have a look here: http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head

Essentially you need to add an action for the wp_head hook, and (probably) remove the other actions that have been associated with the wp_head hook.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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