updating category page titles

google_webmaster

Recently, I was browsing my Google Webmaster Tools account and came across the following duplicate page title errors:

It turns out that by default, my archive pages were just showing the standard WordPress page title and the title does not change as you search backwards in the archive. Google Webmaster Tools complains that this is not following standard best practice of having unique page titles.

To remedy this, I decided to modify my page titles to reflect the archive page number slightly. Before I started, my page title was getting set with the following code in header.php, which sets the page title on the home page to static text, and calls wp_title() for all the other pages:

<title>
<?php if(is_home()) {
echo ‘Pet Photography Winston Salem, Greensboro, High Point | Steph Skardal';
} else {
wp_title(”);
echo ‘ | Steph Skardal Photography';
}
?>
</title>

I looked through the WordPress documentation and settled on the following code:

<title>
<?php if(is_home()) {
echo ‘Pet Photography Winston Salem, Greensboro, High Point | Steph Skardal';
} else if(is_category()) {
echo strip_tags(category_description());
echo ” | page “;
echo (get_query_var(‘paged’)) ? get_query_var(‘paged’) : “1”;
echo ‘ | Steph Skardal Photography';
} else {
wp_title(”);
echo ‘ | Steph Skardal Photography';
}
?>
</title>

Here’s how it breaks down:

  • A conditional is_category() statement is added to be triggered on category pages only.
  • strip_tags(category_description()) returns the category description that I’ve updated on the WordPress category edit page:
  • Next, I return the page number with WordPress’s method get_query_var(‘paged’)).
  • Finally, I add the “Steph Skardal Photography” to the end of the page title.

With these changes, hopefully my pages will be recognized as more unique and perform better in search! I always recommend users look into creating a Google Webmaster Tools account if you haven’t already.

You Might Also Like