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.)
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
Method 2
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0