Home » Internet » Blogging » How to remove blog name from single blog post title in WordPress

How to remove blog name from single blog post title in WordPress



For SEO purposes it is very important that you optimize your blog post titles because titles are very important for search engine optimization. if your WordPress blog name contains many of your keywords and if your blog name appears in the title of all your blog posts it may be considered as spam by search engines.  You need to customize your template in such a manner that only your post title appears within the title tags and not the post title plus the blog name.

You can use one of the conditional tags to decide what sort of title your WordPress blog is going to use and you can use these conditional tags in header.php. Using a conditional tag first you determine whether it is your homepage on a single blog post or page.  You can use the following code:

<title>
<?php
if(is_home())
{
    bloginfo(‘name’);
}
else
{
    wp_title();
}
?>
</title>

This way the blog name only appears within the  title tag when the visitors are viewing your homepage, otherwise just the title of the blog post or the page is published within the title tag.

These days some people prefer to set the particular blog page as their homepage or the front page. for instance if you are using WordPress as a content management system to publish a regular website then you don’t want your homepage to look like a collection of blog posts.  The recent versions of WordPress allow you to create a page and then set this page as your front page.  When you do that the function is_home() does not work.  In case of such a situation arises you should use is_front_page() instead.