WordPress titles

So there’s problems with the default WordPress page titles; Descuentos the display order, and the separator. We’re going to take a look at those problems post – why are they problems? – and we’ll examine some solutions.

The problem with default WordPress titles

The default WordPress title displays something like this:

[blog name] » [category name] » [post title]

There are two key problems here:

  1. Item order: The order of the items in the title should read from most specific to least specific (left-to-right). So Hello the post title should be first, and the blog title should cheap mlb jerseys be last. This makes them more readable and useful in lists of favourites, for example.
  2. The separator: The separator shouldn’t be anything that needs to be escaped and it should be something that comes out nice in screenreaders, too. Here’s an article at 456 Berea Street regarding document titles and separators. I find this comment in particular to be most useful.

The solution

Let’s take echte a look at the standard code:

<title> <?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?> </title>

We’ll reshuffle this as follows:

<title> <?php wp_title(' '); ?> <?php if(wp_title(' ', false)) { echo ' - '; } ?> <?php bloginfo('name'); ?> </title>

So you can see the title of the current page/post comes first. ‘wp_title’ takes an empty string as a parameter; this parameter denotes the separator. We’re not wholesale MLB jerseys using the default, and since we’ve reversed the order, we don’t need wholesale jerseys to display a separator at all.

We then have an ‘if’ statement that checks if the ‘wp-title’ holds a value and displays a separator, ‘ cheap NFL jerseys – ‘, if it does.

Lastly, we display the name of the blog with bloginfo(‘name’).

So now we get this in our title bar:

[post title] – [category name] – [blog name]

Much friendlier!

Some useful links

This entry was posted in Meta, Wordpress. Bookmark the permalink.

4 Responses to WordPress titles

  1. Cheers Dan, I worked out that I can edit the header.php file pretty easily, and it’s all good. I tried the netcocepts plugin, but I kinda broke the blog, so I reverted back. all good now tho

  2. Pingback: two seven » Blog Archive » More WordPress title modification

  3. Zechariah says:

    And there is what some alternative? 😉

  4. fapdex.com says:

    If yοu aгe going for finest contennts like myѕelf, only pay a quick visit tһiѕ website alll the timme forr tһe reason tһat іt ρresents feature ⅽontents, thanks

Leave a Reply

Your email address will not be published. Required fields are marked *