Action Hook since 1.5.0

wp_head

Outputs content in the <head> section

Description

wp_head is the print slot inside document head. Use it for meta tags and inline snippets — not for enqueueing CSS or JS files.

When it runs

Front-end, inside wp_head(). Asset queues are already built by wp_enqueue_scripts; callbacks here print markup.

Signature

do_action( 'wp_head' );

Examples

Basic

add_action( 'wp_head', function() {
    echo '<meta name="theme-color" content="#0073aa">';
} );

Print a theme-color meta tag in the document head.

Real case

add_action( 'wp_head', function() {
    if ( ! is_singular( 'post' ) ) {
        return;
    }
    printf(
        '<meta property="og:title" content="%s">',
        esc_attr( get_the_title() )
    );
} );

Output an Open Graph title only on single posts.

Edge case

add_action( 'wp_head', function() {
    // This never runs in wp-admin.
    if ( is_admin() ) {
        return;
    }
} );

wp_head does not fire in admin screens — put admin CSS on admin_enqueue_scripts.

Common Use Cases

  • Enqueue custom meta tags
  • Output inline styles or scripts
  • Add Open Graph / SEO tags
  • Insert tracking pixels

Common mistakes

  • Enqueueing CSS/JS in wp_head instead of wp_enqueue_scripts
  • Assuming wp_head needs a manual call in a block (FSE) theme — it doesn't; WordPress inserts it automatically around block templates.

Related hooks

FAQ

Should I enqueue scripts in wp_head?

No. Hook wp_enqueue_scripts, then let core print the tags during wp_head.

Does wp_head still fire in a block theme (FSE), since there's no header.php?

Yes. WordPress auto-inserts wp_head()/wp_footer() around the block-based template output, so every callback you register still runs — you just never see or edit the call site yourself.

Source: wp-includes/general-template.php

Group wizard

One session: this hook, then each related_hooks entry. Walk it and tell us what to change.

wp_head → wp_enqueue_scripts → wp_footer

functions.php — wp_head
functions.php
PHP wp_head · Hook 1 of 3 · Step 1 of 7

Practice the wp_head WordPress action hook in our interactive sandbox — a VS Code-style editor with a step-by-step wp_head tutorial, add_action exercises, and instant feedback. No local WordPress install required.