coreyweb

  • Archive
  • RSS
  • Ask me anything

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>
    • #wordpress
    • #SEO
    • #code
  • 8 months ago
  • 10
  • Permalink
  • Share
    Tweet

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
  }
?>
    • #wordpress
    • #code
    • #hack
    • #seo
  • 9 months ago
  • 3
  • Permalink
  • Share
    Tweet

Portrait/Logo

About

a stream of random thoughts, ideas, links & a few hard-to-classify posts

corey brown (aka coreyweb) is the COO/cofounder of Squidoo founder of No Treble, Bright Cowork and Refresh Winchester, plus husband, dad, bassist and instigator.

Elsewhere on the web

  • @coreyweb on Twitter
  • Facebook Profile
  • coreyweb on Flickr
  • coreyweb on Delicious
  • Google
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr