wp_head » Hook no.3

Description

This is a core hook of WordPress and is included in the core Wonderflux header.php file for you. Use this hook to insert items into the <head> of your document. It is important that this remains in all WordPress themes to ensure WordPress and your plugins function correctly.

It should always be inserted directly before the closing </head> code and after the Wonderflux wf_head_meta hook.

Example

In your child theme functions.php file:

<?php
function my_wfx_example_function() {
 echo '<meta name="generator" content="Mike and Ike Tropical Typhoon" />';
}
add_action ('wp_head','my_wfx_example_function');
?>

Notes

Although you could hard-code the echo output function as shown in the example above to include extra scripts like CSS and Javascript, it is is not advised. Instead use wp_register_style() and wp_enqueue_style() for CSS. For scripts like Javascript use wp_register_script() and wp_enqueue_script() – these are core WordPress functions which ensure dependencies are set properly. They also ensure things like Jquery are not included multiple times by accident or when you install well-written WordPress plugins.

This hook documentation was last modified on: August 13, 2011 by Jonny