Archive for the ‘wordpress’ Category

Custom WordPress Meta Titles – Homepage, Pages, Posts

Sunday, January 22nd, 2012

The Meta Title still remains one of the most important content-based SEO factors when determining a web pages ranking in search engines. If you’re like me, and slightly obsessive with your WordPress SEO or like finer control over your WordPress Meta Titles, then the below code snippet can help create custom Meta Titles for the common WordPress page types – including the homepage, pages, individual posts or category archive pages.

These common page types are identified by the below built-in WordPress functions:

  • is_home() will identify the homepage
  • is_single() will recognise an individual blog post page
  • is_category() will identify a category archive section
  • is_page() will identify if a page is visited.

First of all, you’ll want to locate the main “<title></title>” tag. In most themes, there should be a header.php file which will contain all the Meta tags, document declaration, css files and scripts etc. Typical code for existing title tag may look something like:

<title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>.

The wp_title() changes across page types and usually includes the title of your blog page, or title of your post with bloginfo(‘name’) displaying the the blog’s name at the end of the title. In some cases, you may not wish to display the name of your blog on every page, or you may want to have custom page titles for your pages or categories.

By replacing the above line of PHP code with the below chunk, then you can start to give yourself greater custom control over your WordPress Meta Titles:

<?php 
$blog_title = get_bloginfo('name'); 
if (is_home()) {
    $blog_title = get_bloginfo('name') . " | " . get_bloginfo('description');
}
if (is_single()) {
    $blog_title = get_the_title();
}
if (is_category()) {
    $blog_title = single_cat_title("",false) . " archive | " . get_bloginfo('name');
}
if (is_page()) {
    $blog_title = the_title();
} 
 
?>
<title><?php echo $blog_title; ?></title>

With the above code for example, I display the post title only for each of my posts, the homepage has the blog name followed by the blog description and the category archive pages have the category name followed by ‘archive’ and the blog name. You could go even further and name specific pages – the below PHP code will do just that:

if (is_page('page-name-url')) {
 $blog_title = "custom META title";
}

There are also other page types, such as 404 or Tag archive pages, so checkout the full WordPress function list if you need additional page types.

There will be a number of plugins around that will achieve the same or similar outcome but in many cases I prefer getting into the nuts and bolts of the PHP which means I know exactly how my new Meta Titles will look.

Note: It’s worth making a backup of the original code or header.php file. If you already have plug-ins installed to control the Meta Title or other META elements, changing the code for the title may adversely affect the installed plugin.

Renaming your WordPress Blog URL

Saturday, January 22nd, 2011

OK, so if you’re like me and you’ve created your blog, added a post or two and then realised that ‘blog’ just doesn’t sound right, or perhaps you want to get a keyword or two into the main blog URL for better SEO, then it shouldn’t be too tricky to change this without re-installing and setting up your blog.

Note: This post assumes you have installed your wordpress blog at www.yourdomain.com/blog-url/ and you have FTP and database access to your site. These steps worked for me, keeping my existing posts and plug-ins intact but I cannot guarantee that this will work in all cases! (more…)

Remove author & date link from WordPress
(TwentyTen Theme)

Wednesday, January 19th, 2011

This is my first encounter with WordPress (I apologise for the default styling and design!) and I thought how better to start my entry into the blogging world than with a quick post about WordPress itself.

The small issue in question was trying to remove the date link & author name from blog posts in WordPress, (more…)