Eliminate duplicate titles in WordPress category and tag list pages
Thanks to Google Webmaster Tools, I discovered that WordPress was generating duplicate titles for my Category and Tag list pages. Not good.
Say you have a Category named “Videos”. The Category list page shows 10 posts in that category, with “previous” and “next” links to see 10 more.
Like this:
- 1st Category page: http://www.notreble.com/videos
- 2nd Category page: http://www.notreble.com/videos/page/2
- 3rd Category page: http://www.notreble.com/videos/page/3
and so on…
The problem:
WordPress generates the exact same title for each page:
<title>Videos</title>
What it should be doing instead:
- 1st:
<title>Videos</title>
- 2nd:
<title>Videos - Page 2</title>
- 3rd:
<title>Videos - Page 3</title>
and so on…
The fix:
Insert this in your title tag (header.php) of your WordPress theme, and you should be good to go:
<?php
if ($paged > 1) { // if the page is the category index, skip the rule
echo(' - Page '); // the prefix for the page number
echo($paged); // the page number
}
?>
