I’ve whittled things down to the point where the only baseline change from WordPress 2.0.2 is in the next_posts_link function of the wp-includes/template-functions-links.php file. The change is necessary because WPopac rewrites the SQL search queries in a way that’s incompatible with a piece of this function, but necessary for performance reasons.
Here’s how my version reads:
function next_posts_link($label='Next Page »', $max_page=0) {
global $paged, $result, $request, $posts_per_page, $wpdb, $max_num_pages;
if ( !$max_page ) {
if ( isset($max_num_pages) ) {
$max_page = $max_num_pages;
} else {
preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
// added April 5 2006 by Casey Bisson to support WPopac
// necessary because the preg_match above fails with some queries
if(!$fromwhere)
$fromwhere = $wpdb->posts;
// changed April 5 2006 by Casey Bisson to speed the query by eliminating
// the slow DISTINCT clause
//$numposts = $wpdb->get_var(“SELECT COUNT(DISTINCT ID) FROM $fromwhere”);
$numposts = $wpdb->get_var(“SELECT COUNT(*) FROM $fromwhere”);
$max_page = $max_num_pages = ceil($numposts / $posts_per_page);
}
}
if ( !$paged )
$paged = 1;
$nextpage = intval($paged) + 1;
if ( (! is_single()) && (empty($paged) || $nextpage < = $max_page) ) {
echo '<a href=“';
next_posts($max_page);
echo '”>'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
}
}
baseline modification, hack, mysql query optimization, wordpress, wordpress hacking, wpopac
Posted April 17, 2006 by Casey Bisson
Categories: Libraries & Networked Information, Technology. Tags: baseline modification, hack, mysql query optimization, wordpress, wordpress hacking, wpopac.
No Comments
No comments yet.
Comments RSS
TrackBack Identifier URI
Leave a comment
User contributed tags for this post:
wordpress next posts link (53) - chernobyl videos (18) - baseline changes (5) - next posts link wordpress (5) - networked information (4) - wordpress max num pages (4) - wpopac (4) - free xxl com (3) - max num pages (3) - free girls com (3) - next posts link (3) - sex (3) - wordpress posts per page (2) - numposts wpdb get var SELECT COUNT DISTINCT ID FROM fro (2) - sex 3 (2) - wpopac wordpress (2) - recently commented wordpress mysql (2) - support for google hearth (2) - next posts link Wordpress 2 2 (1) - wordpress global paged (1) - next posts link wordpress support (1) - wordpress next posts link for pages (1) - select distinct id (1) - baseline wordpress (1) - a sexs changes (1) - cache CpBNBPu282EJ maisonbisson com blog post 11264 num (1) - wordpress if next posts (1) - counting all comments wordpress (1) - Wordpress Baseline templates (1) - $wpdb->getvar (1) - wordpress paged comment hack (1) - wordpress mysql query link (1) - mysql hacking video (1) - was wpopac (1) - select count id (1) - next posts link category rewrite (1) - download wpopac (1) - wordpress posts per page next posts (1) - free xxl (1) - wordpres next posts link (1) - chernobyl Wordpress (1) - wordpress next posts link search (1) - wordpress pages next posts link (1) - preg porno (1) - wordpress (1) - free indian xxx com (1) - wordpress next posts link function (1) - which file is next posts link in (1) - if next posts link (1) - select count distinct (1) - wordpress mysql global (1) -