Remove » from WordPress title tag

raquoFirst an intro to what this character is and where it comes in from before removing it from WordPress post title tag. The character “»” is: “»” that WordPress places by default before the title of any single post or page of your WordPress blog. In this post we will discuss ways to remove it and to change it to something else, including the best way (imho). No trimming with trim(wp_title()) it is “not” a good way, bad idea! use the proper way and not what we call “jugaar” in Urdu.

Best way to simply remove » from wordpress title

The best way to simply remove » (») from wordpress title is to goto your wordpress theme files and edit header.php to replace:

wp_title();

with:

wp_title('');

This will simply do the task which you’re trying to do and will remove the » code from the beginning of the wordpress title.

If you want to understand how it happened or if you want to “modify” the title more and not just remove that string from the title, then continue reading through the post.

How wp_title() works

Wp_title() is a builtin function of wordpress which displays the current pages title in the title tag for your wordpress blog. Now we have just seen how it works by default. Now lets go in detail.

The wp_title() function accepts three parameters in this sequence:

  • $sep (seperator)
  • $display (yes or no)
  • $seplocation (to the right or left of the title)

Now when we use it without any of the variable provided, wordpress does what’s encoded in it by default, it shows » (») to the left of the title.

Now if we want to replace it with any other character, we need to provide the new character we want, it can be a blank space like ‘ ‘ or ‘|’ or a hyphen ‘-‘ or any single or multiple characters which we want. The next variable will define to show or not to show the separator and the last one will define it’s location, to the left or right of the title, i.e, before or after the original title tag of the post.

Example of a blank separator in WordPress title tag using wp_title()

This example will display nothing as seperator for title tag in your post after the title, not even the default » (»)

 wp_title(”);

Yes it was that simple :) Hope it helps you remove the » tag before the title of your WordPress post.

2 comments on “Remove » from WordPress title tag

  1. This method only breaks the PHP and causes an error. The fact that we need to research how to remove a special character from WordPress build-in title hook, is one of the main reasons why WordPress is so primitive.

Leave a Reply

Your email address will not be published.