• Using the new version of pagebar added over 100 database hits (queries) to every page on my site, including those that didn’t incorporate the pagebar!

    If you need a replacement, try adding this to your functions.php file: (Tweak it if necessary) – call the function using my_pagebar();

    // ========= My Pagebar Replacement Function
    
    function my_pagebar() {
    global $paged;
    global $ppp;
    global $search_results;
    
    if (empty($ppp)) { $ppp = 12; };
    $num_pages = ceil($search_results/$ppp);
    if ($num_pages > 1) {
    	$current_search_link = 'https://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    	$add_page = "/page/";
    	if ($paged) {
    		$current_search_link = preg_replace('#\d+$#', '', $current_search_link);
    		$add_page = "";
    	}
    	$mypagebar = '<div class="pagebar">Pages:&nbsp;';
    	if ($paged == 0) { $paged = 1; }
    	$x = 1;
    	while ( $x <= $num_pages ) {
    		$y = $paged - 2;
    		$z = $paged + 2;
    		if ( $x == $paged ) {
    			$mypagebar .= "<span class=\"this-page\">$x</span> ";
    		} elseif ( ($x < 4) || (($num_pages - 3) < $x) || ($x >= $y && $x <= $z) ) {
    			$mypagebar .= "<a href=\"{$current_search_link}{$add_page}{$x}\" title=\"Page $x\">$x</a> ";
    		} elseif (($x < $paged) && ($did_the_b4 != 1)) {
    			$mypagebar .= " ... ";
    			$did_the_b4 = 1;
    		} elseif (($x > $paged) && ($did_the_aft != 1)) {
    			$mypagebar .= " ... ";
    			$did_the_aft = 1;
    		}
    		$x++;
    	}
    	$mypagebar .= "</div>";
    }
    echo $mypagebar;
    }
  • The topic ‘[Plugin: pagebar] WAY too many database hits!’ is closed to new replies.