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').
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.
Source
Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |