Apr 18

Updated PagerFix Plugin Code For WP 2.1

Posted by Jaimie Sirovich on Apr. 18th, 2007. 5 comments — voice your opinion.

BECOME AN EGGHEAD. SUBSCRIBE TO OUR RSS FEED OR FOLLOW US ON TWITTER!

Learn to be as nerdy as we are by never missing our latest blog entries. Receive great tips, tricks, and ideas on improving your web site every day! Subscribe via our RSS Feed, follow us, or use the chicklets in the sidebar for more options.
X

I upgraded to WordPress 2.1 today, and one of my plugins blew everything up. Here it is revised for WordPress 2.1. Enjoy!:

Download source code here

<?php

/*
Plugin Name: PagerFix
Plugin URI: http://www.seoegghead.com/
Description: Makes the paging in WP more SE-friendly.
Author: Jaimie Sirovich
Version: 1.1 for WP 2.1+
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 
$posts_per_page$paged$wp_query;
    
    
posts_nav_link(",$prelabel,");
    echo 
$after_previous;
        
    
$numposts $wp_query->found_posts;
    
    
$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);
    
}

?>

The old documentation/blog post is here.

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



Related posts:
Stop SEO Death By Pagination This post is now (mostly) obsolete and replaced by WordPress...
Patched Sociable Code To Enable Feed Icons I said I would release this if enough people asked. ...
Find HTML Injection Vulnerabilities with Google Code Search I guess I think like a hacker, because I thought...
Yahoo API Code <?php /* sample usage: $tree = new xmlTreeParser('sample.xml'); echo '<pre>'; print_r($tree->getTree()); */ class xmlTreeParser {     var $_parser;     var $_xmldata;...
Code for HTML Auditing <? // +———————————————————————-+ // | HTMLParser                                                           | // | Simple HTML Parsing Library                                          | // | Based on Jose Solorzano's Library; his notice is below.              | // +———————————————————————-+ // | Portions Copyright (c) 2004-2005 Jaimie Sirovich                     | // +———————————————————————-+ // | This program is free software; you can redistribute it and/or        |...




"5 Wise Comments Banged Out Somewhere On The Internet ..."


Dog

Nice plugin, but it seems to break my RSS feed generation.

Looking for the glitch now.

Cheers

Dave

Royce Tivel

I recently installed WampServer on my local PC. I then installed WordPress 2.7. When I loaded pagerfix from this web page, it would not run. I have been using this version of pagerfix at two online locations without any problem.

The problem turns out to be in the very first line of the code: <?. This needs to be changed to <?php. Apparently, WampServer, "out of the box" is a bit more critical about PHP code.

I know there is a later release of the plugin; but I confess, I like this simple, "mean and lean" version–especially before I have thoroughly tested the new version.

My advice is to make the code change on the source code shown above so that others do not encounter this problem.

Jaimie Sirovich

It's fixed on the download page.

Can Excessive Outbound Linking Hurt Your Rankings? | Search Engine Optimisation & Online Marketing Ireland .:. Red Cardinal

[...] inherent pagination issues. These can be solved using Jamie Sirovich's excellent PagerFix [...]

WordPress subpages going supplemental: the fix - SEO Blog - Joost de Valk

[...] changed the pagination using Jaimie's pagerfix plugin which he was kind enough to update for WordPress [...]



Care To Bang On The Keys ... ?

BECOME AN EGGHEAD. SUBSCRIBE TO OUR RSS FEED!

Learn to be as nerdy as we are by never missing our latest blog entries. Receive great tips, tricks, and ideas on improving your web site every day! Subscribe via our RSS Feed or use the chicklets in the sidebar.