coreyweb

  • Archive
  • RSS
  • Ask me anything

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
  • 6 months ago
  • Permalink
  • Share
    Tweet
← Previous • Next →

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