How to avoid duplicate meta descriptions in pages 2 and higher of the Wordpress loop 7
I have written before of the problems of Wordpress comment pagination and duplicate content and how to get unique meta descriptions in wordpress.
I have now solved the problem of all pages in the Wordpress loop having identical titles and meta descriptions.
The problem
Whether it's your main index page or a category or tag page, Wordpress works in the same way. It shows the latest, say, 10 posts. And it then gives you a next link to click. If you click next, the URL will be very similar, but will have /page/2/ on the end. And it will show the next posts.
However, this second page (and any third, fourth, fifth etc pages) will all have the same titles and meta descriptions. This will confuse google.
The solution
The answer is to include the page number in the title and meta description of subsequent pages of the loop.
Here's some code to let you do this:
<?php if ( $paged < 2 ) { } else { echo (' Page '); echo ($paged);} ?>
What this does is to check whether the page is the first one or is page 2 or higher.
If it's page 1, nothing happens. On page 2 or higher, it adds: Page 2 (or 3, or whatever).
So just add this code after the code that is generating your meta description or title.
An example
The code to generate my title looks like this:
<title><?php wp_title('»', true, 'right'); ?> <?php bloginfo('name'); ?>
<?php if ( is_home() ) {echo (' - Reviews, SEO, wordpress, how to do things ...');}
?>
<?php if ( $paged < 2 ) {
} else {
echo (' page ');
echo ($paged);
} ?>
</title>
So if you go here, it should say 'page 2' at the end of the title (check your browser bar to see it).
You might also like
- Avoid duplicate content with paged comments in wordpress
- Unique meta description and meta keyword tags in your Wordpress themes
- Wordpress comment pagination & duplicate content
- Twitter’s latest SEO improvement: meta descriptions
- Can you use rel = canonical to fix duplicate comment problems caused by comment pagination in wordpress?


This is the personal blog of Malcolm Coles.
Nice work-around but unfortunately I am using the All-in-one SEO plugin and this trick doesn't seem to apply to it. If anyone knows of a way of getting this working with that plug-in, it would be very useful for a lot of people.
I've recently had to add unique meta descriptions into WordPress but so far none of my posts have been long enough to require a second page and I had not considered this issue.
I'll now add this solution into my blog so that I don't run into problems when I do create posts long enough for a multiple pages.
Many Thanks.
Laurens - because All In One Seo generates the titles and meta descriptions itself, you can't use this trick with it. Well, you could - you could rewrite the PHP in the plug-in. Let us know how you get on!!!
All in one does not generate meta keyword and descriptions for Paged pages, or Tag pages, at least not for me. It deals with the Tag page titles and the Paged page titles, but not the meta. To get meta data in those groups of pages, I added two parts of code, one for the Tag pages, the other for the Paged pages in the theme header.php file. I'm not a programmer (or even close), so here is the code I assembled from various sources (here included) to have a go at. I assume it could be done more compactly or elegantly or both, but it works! The object was to have a different description for each Tag page by dynamically inserting the title of the Tag page in the front of the description in a grammatically correct way, and for each Paged page by dynamically inserting the page number in a readable fashion as well. And when I say it works, it means I don't know what it might be screwing up.... but that the meta appears in the source code of the Paged and Tag pages and everything seems OK.
<?php if (is_tag()) { ?>
<meta name="description" content="<?php single_tag_title(''); ?> at my description"/>
<meta name="keywords" content="my keywords"/>
<?php } ?>
<?php if (is_paged()) { ?>
<meta name="description" content="<?php if ( $paged < 2 ) { } else { echo ('Blog Page '); echo ($paged);} ?> at at my description"/>
<meta name="keywords" content="my keywords"/>
<?php } ?>
Hi Malcom. I did come across one issue with the code. If the page is a TAG page that is the second page for a particular Tag (we have 15 posts per page, so a Tag that was attached to more than 15 posts would create a second page), wordpress treats this 2nd page as a Paged page in addition to a Tag page and with my code, puts up both sets of meta data on that page. Any suggestions for a code fix to resolve this.... such as if it's a Tag, then don't go to step 2 (the paged step) in the code.... something like that?
This is what I do if it's any help (NB the Metadescription bit is a custom field). You could check out Christian's site - he's edited the all in one plugin to include the method described here.
<meta name="description" content="
<?php
if(is_home()) {echo ('Malcolm Coles: His blog for his reviews, so you can find him, and other stuff that takes his fancy.');}
else
{if(is_category()) {echo category_description();}
else {if(is_tag()) {echo '-tag archive page for this blog' . single_tag_title();}
else {if(is_month()) {echo ' archive page for this blog' . the_time('F, Y');}
else {echo get_post_meta($post->ID, "Metadescription", true);}
}}}
?>
<?php if ( $paged < 2 ) {
} else {
echo (' Page '); echo ($paged);
} ?>">
HI Malcom. I'm sure your code is better... since I don't have a clue!!! I will look at it, and get back. I did resolve the issue of when something is both a Tag and Paged....not duping the meta tags (one set for each)... which is half good news :). I'll get back in the next day or two after looking more at the code.... Thanks Malcom........