wp_head()
Triggers the hook event wp_head. Called in the header of the site in the file: header.php
wp_head() is a Template Tag that should be inserted before </head>, in the theme files: header.php or index.php, if header.php is not used.
For more details, read the event description wp_head
There is a similar function that works for the footer: it triggers the hook wp_footer in the footer of the site: wp_footer().
Uses: do_action()
Hooks from the function
Returns
null. Returns nothing.
Usage
<?php wp_head(); ?>
Examples
#1 Mandatory function call in the header of any theme
Plugins and WordPress core use this function to insert crucial elements into your document (e.g., scripts, styles, and meta tags). Always put wp_head() just before the closing </head> tag of your theme (in header.php):
<head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <meta name="viewport" content="width=device-width" /> <?php /** * wp_head() must always be in front of </head> * otherwise the work of many plugins will be disrupted, which * use this hook to add their codes to <head>. These are: * styles, scripts and meta tags. */ wp_head(); ?> </head>
Changelog
| Since 1.2.0 | Introduced. |
wp_head() wp head code WP 6.9.1
function wp_head() {
/**
* Prints scripts or data in the head tag on the front end.
*
* @since 1.5.0
*/
do_action( 'wp_head' );
}