Fix for Categories and Previous/Next links in WordPress 2.6.2 + Gengo
After a long winter we had a very nice long weekend last week which we spent 9 hours (driving) north from Sydney, next to the NSW/QLD border. I’ve already published some images from that trip, but still working on night shots.
Anyway, I’ve decided that I must fix broken Categories and Previous/Next links on this site and spent some time debugging Word Press and bunch of Word Press plug-ins.
As I couldn’t find an easy fix for both problems, here is what you can do if you’re using Gengo and have problems (looping and error 404) with previous/next page links after upgrading to WordPress 2.6.
 In “gengo.php” change the following function from:
           function get_pagenum_link($link){
                       global $wpdb;
                       if(get_option(‘permalink_structure’)!=””):
                       $block = explode(“/page”,$link);
                       if(isset($block[2]) && $block[2]!=””):
                                   $newurl = $this->append_links($block[0].”/page”.$block[2]);
                       elseif($block[1]==”/2/” && !isset($block[2])):
                                   $newurl = $block[0].”/page”.$block[1];
                       else: $newurl = $this->append_links($block[0]); endif;
                       return $newurl;
                       else: return $link; endif;
           }
to:Â
           function get_pagenum_link($link){
                   global $wpdb;
                       if(get_option(‘permalink_structure’)!=””):
                       $block = explode(“/page”,$link);
                       if(isset($block[2]) && $block[2]!=””):
                                   $newurl = $this->append_links($block[0].”/page”.$block[2]);
                       elseif($block[1]==”/2/” && !isset($block[2])):
                                   $newurl = $block[0].”/page”.$block[1];
                       elseif($block[1]==”/2″ && !isset($block[2])):
                                   $newurl = $block[0].”/page”.$block[1].”/”;
                       else: $newurl = $this->append_links($block[0]); endif;
                       return $newurl;
                       else: return $link; endif;
           }
There can be another better solution for this, but I’ve decided not to modify (read break) what is already there and add some code that fixes my problem.
As for broken categories, read this article: http://blog.cumps.be/wordpress-26-upgrade-fix-missing-categories/
I’ve decided to delete all categories and re-categorise all posts manually – it was quicker and I had to do that anyway.