Avoiding Duplicate Titles in WordPress Media Attachments
Looking through Google Webmaster tools, I discovered a warning about duplicate title tags coming from WordPress media attachment pages, like this one.
Here is a quick fix (place inside the
of header.php:
<?php if ( is_attachment() ) { ?>
<meta name="robots" content="noindex, nofollow" />
<?php } ?>
You can also adjust your title tag, to include some sort of prefix, like this:
<title>
<?php if ( is_attachment() ) { ?>Attachment: <?php } ?>
<!-- include your normal title stuff here -->
</title>
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
}
?>
