Title: wp_head
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_head()

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#description)
 * [Source](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#wp--skip-link--target)

Fires the wp_head action.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#description)󠁿

See [‘wp_head’](https://developer.wordpress.org/reference/hooks/wp_head/).

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#source)󠁿

    ```php
    function wp_head() {
    	/**
    	 * Prints scripts or data in the head tag on the front end.
    	 *
    	 * @since 1.5.0
    	 */
    	do_action( 'wp_head' );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/general-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/general-template.php#L3191)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/general-template.php#L3191-L3198)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#hooks)󠁿

 [do_action( ‘wp_head’ )](https://developer.wordpress.org/reference/hooks/wp_head/)

Prints scripts or data in the head tag on the front end.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#related)󠁿

| Uses | Description | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  |

| Used by | Description | 
| [WP_REST_Widget_Types_Controller::render_legacy_widget_preview_iframe()](https://developer.wordpress.org/reference/classes/wp_rest_widget_types_controller/render_legacy_widget_preview_iframe/)`wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php` |

Renders a page containing a preview of the requested Legacy Widget block.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#changelog)󠁿

| Version | Description | 
| [1.2.0](https://developer.wordpress.org/reference/since/1.2.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#comment-content-900)
 2.    [hearvox](http://hearingvoices.com)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/wp_head/#comment-900)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_head%2F%23comment-900)
     Vote results for this note: 15[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_head%2F%23comment-900)
 4.  Example. 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  tag of your theme (usually in `header.php`):
 5.      ```php
         <head>
         	<!-- First add the elements you need in <head>; then last, add: -->
         	<?php wp_head(); ?>
         </head>
         ```
     
 6.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_head%2F%3Freplytocom%3D900%23feedback-editor-900)
 7.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/wp_head/?output_format=md#comment-content-5600)
 8.    [thejaydip](https://profiles.wordpress.org/iamjaydip/)  [  4 years ago  ](https://developer.wordpress.org/reference/functions/wp_head/#comment-5600)
 9.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_head%2F%23comment-5600)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_head%2F%23comment-5600)
 10. Add a pingback url auto-discovery header for single posts, pages, or attachments.
 11.     ```php
         if ( ! function_exists( 'wpdocs_pingbackurl_example' ) ) {
         	function wpdocs_pingbackurl_example() {
         		if ( is_singular() && pings_open() ) {
         			echo '<link rel="pingback" href="' . esc_url( get_bloginfo( 'pingback_url' ) ) . '">';
         		}
         	}
         }
         add_action( 'wp_head', 'wpdocs_pingbackurl_example' );
         ```
     
 12.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_head%2F%3Freplytocom%3D5600%23feedback-editor-5600)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_head%2F)
before being able to contribute a note or feedback.