Filter Hook since 0.71

wp_title

Filters the document <title> tag

Description

wp_title is the classic document-title filter. Modern themes should prefer document_title_parts — this hook remains for older title tags.

When it runs

When wp_title() is called directly by a theme's header.php. Block/modern themes usually use document_title_parts instead.

Signature

apply_filters( 'wp_title', string $title, string $sep, string $seplocation );

Parameters

  • $title string — Title text.
  • $sep string — Separator.
  • $seplocation string — left or right.

Examples

Basic

add_filter( 'wp_title', function( $title, $sep ) {
    return $title . $sep . get_bloginfo( 'name' );
}, 10, 2 );

Append the site name to the classic title output.

Real case

add_filter( 'wp_title', function( $title, $sep, $seplocation ) {
    if ( is_feed() ) {
        return $title;
    }
    return 'left' === $seplocation ? get_bloginfo( 'name' ) . " $sep $title" : $title;
}, 10, 3 );

Skip the filter for feeds and control separator placement manually.

Common Use Cases

  • Customize SEO page titles on legacy themes
  • Append site name to titles
  • Set title format for specific pages
  • Override title for 404 pages

Common mistakes

  • Hooking wp_title on a block/modern theme that never calls wp_title() — use document_title_parts instead

Related hooks

FAQ

Is the wp_title filter deprecated?

The wp_title() template tag is legacy — modern themes render titles via wp_get_document_title() and the document_title_parts filter. wp_title only fires if a theme still calls wp_title() directly in header.php.

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_title → the_title → document_title_parts

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

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