This post is now (mostly) obsolete and replaced by WordPress SEO Pager —

WordPress SEO Pager

I know of many architectural mistakes that can totally torpedo a web site's rankings — using URL-based session IDs, adding duplicate content for fun, etc.  But one thing stands out in WordPress blogs as a culprit.  I call it "death by pagination," and it's another way to screw yourself.

It's common knowledge that pages buried deeply within a web site, for various reasons, will likely not rank as well as those that are linked from top-level pages.  Typically, the solution employed is a site map.  This mitigates the problem by creating one link to deeper pages from a page that is only 1 level deep.

Without that, simple "< prev next >" pagination causes certain items (in this case posts), to be buried several pages deep within a site structure that looks like this:

[ A -> B -> C -> D ]

Here, page "D" is 4 levels deep.  Usually, it's not linked from anywhere else, either.  In a blog, this would occur when the pagination is performed in 10s, and there are >= 31 posts in a category or month.  On my blog, that's pretty likely, and the first post in a given month would be on page "D."  Categories only get larger over time as well.

There are two approaches to fixing the problem.

1. Don't use simple-pagination.  Page with "< prev" and "next >" as well as links to the individual pages.
2. Add a sitemap

Examples of "1" can be seen on this page on one of my sites and also on the SEOmoz blog:

 

To do this in wordpress, add this little plugin:

<?

/*
Plugin Name: PagerFix
Plugin URI: http://www.seoegghead.com/
Description: Makes the paging in WP more SE-friendly.
Author: Jaimie Sirovich
Version: 1.0
Author URI: http://www.seoegghead.com/
*/ 

function pager_fix($seperator ' | '$after_previous '&nbsp;&nbsp;'$before_next '&nbsp;&nbsp;'$prelabel='&laquo; Previous Page'$nxtlabel='Next Page &raquo;'$current_page_tag 'b')
{    
    global 
$request$posts_per_page$wpdb$paged;
    
    
posts_nav_link('',$prelabel,'');
    echo 
$after_previous;
    
preg_match('#FROM (.*) GROUP BY#'$request$matches);
    
$fromwhere $matches[1];
    
$numposts $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere");
    
$max_num_pages ceil($numposts $posts_per_page);

    if ($max_num_pages 1) {

        for ($cnt 1$cnt <= $max_num_pages$cnt++) {

            if ($current_page_tag && $paged == $cnt) {
                
$begin_link "<$current_page_tag>"$end_link "</$current_page_tag>";
            } else {
                
$begin_link ''$end_link '';
            }
            
            
$x[] = $begin_link '<a href="' get_pagenum_link($cnt) . '">' $cnt '</a>' $end_link;
            
        }
    
        echo 
join($seperator$x);
        
    }
    echo 
$before_next;
    
posts_nav_link('','',$nxtlabel);
    
}

?>

Then call the function "pager_fix()" in your template somewhere.

To accomplish "2," use this plugin.  I use this plugin — here is my sitemap.

Side Note: You can also use the links generated by the calendar control in WordPress to partially address this; but I feel this introduces other problems, including duplicate content issues.  For this reason I do not recommend it.

Of course this concept does not only apply to blogs.  I see plenty of other web sites that would benefit from fixing their paging features up like this.

Tell an amigo:
  • Sphinn
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon
  • Facebook



Related posts:
Updated PagerFix Plugin Code For WP 2.1 I upgraded to WordPress 2.1 today, and one of my...
WordPress "SEO Pager" Pagination Control Plugin Released! You like SEO and intuitive pagination controls? Well, we decided...
3 WordPress Hacks For SE-Friendly Blog Archives Your default WordPress installation has a problem.  Your posts slowly...
Stop Hackers With Our WordPress Firewall Plugin v1.2 Getting hacked is a total bummer, right? Right. But...
How You Can Stop Dirty Feed Scrapers In 3 Easy Steps Stealing is wrong; but some people just don't seem to...