wp_title WordPress Filter Hook

The wp_title hook is one of the most important hooks in WordPress. It allows you to change the title of your WordPress site. This can be useful if you want to change the title of your site to something more unique or if you want to change the title of your site to match the content of your site.

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

Filters the text of the page title.


Parameters

$title

(string)Page title.

$sep

(string)Title separator.

$seplocation

(string)Location of the separator ('left' or 'right').


Top ↑

More Information

The wp_title filter is used to filter the title of the page (called with wp_title()). This filters the text appearing in the HTML <title> tag (sometimes called the “title tag” or “meta title”), not the post, page, or category title.

A plugin (or theme) can register as a content filter with the code:

add_filter( 'wp_title', 'filter_function_name', 10, 2 );

Where ‘filter_function_name’ is the function WordPress should call when the content is being retrieved. Note that the filter function must return the content after it is finished processing, or the title will be blank and other plugins also filtering the content may generate errors.

filter_function_name should be unique function name. It cannot match any other function name already declared.


Top ↑

Source

File: wp-includes/general-template.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
2.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More