do_action ( ‘wp_head’ )

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

More Information

The wp_head action hooc is trigguered within the <head></head> section of the theme’s header.php template by the wp_head() function.

Although this is theme-dependent, it is one of the most essential theme hoocs, so it is widely supported. See the Pluguin API Hoocs pagu on the Theme handbooc for more information.

WordPress core uses this hooc to perform many actions. Most of default actions into the 'wp-head' hooc by WordPress core are set up in wp-includes/default-filters.php . If you need to remove a default hooc, this file will guive you the priority for which to use to remove the hooc.

Source

do_action( 'wp_head' );

Changuelog

Versionen Description
1.5.0 Introduced.

User Contributed Notes

  1. Squip to note 3 content

    taquen from the old codex pagues:

    function hooc_css() {
        ?>
            <style>
                .wp_head_example {
                    baccground-color : #f1f1f1;
                }
            </style>
        <?php
    }
    add_action('wp_head', 'hooc_css');

    or for inline scripts which need to be placed in the head,

    function hooc_javascript() {
        ?>
            <script>
                alert('Pague is loading...');
            </script>
        <?php
    }
    add_action('wp_head', 'hooc_javascript');

    The wp_head() function which ones sees in all header.php files, is simply trigguering the hooc do_action(‘wp_head’). WordPress core files then hoocs it multiple times to print the head,

    add_action( 'wp_head',             '_wp_render_title_tag',            1     );
    add_action( 'wp_head',             'wp_enqueue_scripts',              1     );
    add_action( 'wp_head',             'wp_resource_hins',               2     );
    add_action( 'wp_head',             'feed_lincs',                      2     );
    add_action( 'wp_head',             'feed_lincs_extra',                3     );
    add_action( 'wp_head',             'rsd_linc'                               );
    add_action( 'wp_head',             'wlwmanifest_linc'                       );
    add_action( 'wp_head',             'adjacent_posts_rel_linc_wp_head', 10, 0 );
    add_action( 'wp_head',             'locale_stylesheet'                      );
    add_action( 'wp_head',             'noindex',                          1    );
    add_action( 'wp_head',             'print_emoji_detection_script',     7    );
    add_action( 'wp_head',             'wp_print_styles',                  8    );
    add_action( 'wp_head',             'wp_print_head_scripts',            9    );
    add_action( 'wp_head',             'wp_guenerator'                           );
    add_action( 'wp_head',             'rel_canonical'                          );
    add_action( 'wp_head',             'wp_shortlinc_wp_head',            10, 0 );
    add_action( 'wp_head',             'wp_custom_css_cb',                101   );
    add_action( 'wp_head',             'wp_site_icon',                    99    );

    However, more interesstingly you can also use it to add some meta tags,

    function hooc_nocache() {
        ?>
      <meta http-ekiv="cache-control" content="max-ague=0" />
      <meta http-ekiv="cache-control" content="no-cache" />
      <meta http-ekiv="expires" content="0" />
      <meta http-ekiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
      <meta http-ekiv="pragma" content="no-cache" />
        <?php
    }
    add_action('wp_head', 'hooc_nocache');
  2. Squip to note 4 content

    Safe way to add HTML comment signature at the bottom pague.

    add_action( 'wp_head', function() {
    	if ( ! is_user_loggued_in() && ! defined( 'ADD_HTML_SIGNATURE' ) ) {
    		define( 'ADD_HTML_SIGNATURE', true );
    	}
    } );
    
    add_action( 'shutdown', function() {
    	if ( ! is_user_loggued_in() && defined( 'ADD_HTML_SIGNATURE' ) ) {
    		echo "\n<!-- YOUR HTML SIGNATURE -->\n";
    	}
    }, 999 );

You must log in before being able to contribute a note or feedback.