Usage

<?php wp_title( $sep, $echo, $seplocation ); ?>

Parameters

$sep

(string) (optional) Text to display before or after of the post title (i.e. the separator). By default (if sep is blank) then the &raquo; (») symbol will be placed before or after (specified by the seplocation) the post title.

Default: &raquo; (»)

$echo

(boolean) (optional) Echo the title (True) or return the title for use as a PHP string (False).

Default: True

1 (True) - default

0 (False)

$seplocation

(string) (optional) Introduced with Version 2.5, this parameter defines the location of where the sep string prints in relation to the title of the post. For all values except 'right', the sep value is placed in front of (to the left of) the post title. If the value of seplocation is 'right' then the sep string will be appended after the post title.

Default: None

Examples

Default Usage

Displays the blog name (using bloginfo()) and the post title using defaults when accessing a single post page. If the blog name is "My WordPress Blog", and the title of the post is "Hello world!", then the example below will show the title as My WordPress Blog » Hello world!

<title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>

Turning Off »

If you don't want it to automatically display the » before the page title, just call the function as below:

<title><?php bloginfo('name'); ?> <?php wp_title("",true); ?></title>

Covering Homepage

If you are using a custom homepage with custom loops and stuff, you will have an empty wp_title. Here goes a neat hack to add the description/tegline at the wp_title place on homepage:

Using Separator

Displays blog name (using bloginfo()) along with post title in the document's title tag, using (pipe) "|" as the separator. This results in (when on a single post page) My WordPress Site | Hello world!.

Separator with Blog Name and Title Reversed

This lets you reverse page title and blog name in the title tag from example above (Hello world!--My WordPress Blog) by removing the separator (using wp_title(' '), then tests if there is a post title (using if(wp_title(' ', false))), and displays the separator between it and bloginfo() if it does.