Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Talk:Function Reference/wp title

The default usage of this tag puts an arrow or designated symbol (dash - long line pipe) BEFORE the title assuming that the usage is BLOG NAME - TITLE but we are getting people who want TITLE - BLOG NAME and they get - TITLE BLOG NAME. Can we put an example in that shows how to use "nothing" and not a space before the TITLE so they could use something like this:

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

Thanks, Lorelle 15:29, 12 May 2005 (UTC)

For the same reason you don't use HTML tags in your document's title, you don't want "advanced" character entities (they're not translated by most browsers). But whatever separator used, your example will display it even when the blog name is alone in the title, something I suspect most users don't care for. I recommend for those who want to reverse blog name and page title to look at the Optimal Title plugin.
Kaf 16:58, 12 May 2005 (UTC)
The character entity was off the top of my head to emulate the forum post's request. You're right on that. Should something about the order of the wp_title() and the separator in the article? We can or cannot mention the plugin but the fact that some kind of separator has to be there (if "nothing" is possible to include like wp_title(' ') ) ? Thanks, Kaf. Lorelle 21:03, 12 May 2005 (UTC)
You can use a space, but for those who want a visual separator between title and blog name the problem is where it displays (especially when swapping the order). Anyway, I'm not fond of giving a nod to plugins on the tag pages, so I'll build an example that tests whether wp_title() outputs anything, and displays the separator (or not) based on that. I'll also add something to the sep param description.
Kaf 03:14, 13 May 2005 (UTC)
Return value for wp_title("",false)

There seems to be an extra empty character appended on to the front of this return value, as well as an added space, depending on your $seplocation parameter. This can complicate the string comparison process, considering there is no documentation on this. You can confirm the existence of the empty character by doing a str_split(wp_title("",false)) and then print_r your array.
Jml6m 21:27, 23 June 2013 (UTC)

I've went ahead and added a blurb about this in the "Return Values" section
Jml6m 20:17, 25 June 2013 (UTC)

Ambiguous: "The Loop on the main page"

The page currently reads, "This tag can be used anywhere within a template as long as it's outside The Loop on the main page..." and I am editing it to say something like, "You can use it anywhere within a template except in The Loop on the main page," but because I do not know the definition of "main page", I do not understand what this means. Will someone please modify the page to clarify the limitation? Hunterhogan 06:29, 19 March 2014 (UTC)


Hi Hunter, I've updated the page to clarify this. I removed any mention of using the function anywhere else within a template, because that really isn't its intended use (and I'm not sure why it said that it shouldn't be used on the main page). I think there is still some more work that could be done here, especially in the parameters section, so I've marked the article for copyediting.
-Jdgrimes 13:13, 19 March 2014 (UTC)