Wordpress Pagination Help...

There is pagination on a Wordpress plugin I’m using and I not getting any response from the writer.

Basically I just want to find out how to display the pagination like this:
<< 1 2 3 4 … 20 >>

It would be great if anyone could help. Thanks in advance.

Here is the code:
[php] $pr = get_option(‘frp_rpp’); // rows per page
$page = isset($_GET[‘page’]) ? (int) $_GET[‘page’] : 1;

// BEGIN PAGINATION HEAD
if($competition != '')
	$pages = implode(mysql_fetch_assoc(mysql_query("SELECT COUNT(*) FROM `$tbl_match` WHERE DATE_ADD(matchdate, INTERVAL matchtime HOUR_SECOND) <= NOW() AND competitionyear = '$year' AND competition = '$competition' ORDER BY matchdate DESC")));
if($competition == '')
	$pages = implode(mysql_fetch_assoc(mysql_query("SELECT COUNT(*) FROM `$tbl_match` WHERE DATE_ADD(matchdate, INTERVAL matchtime HOUR_SECOND) <= NOW() AND competitionyear = '$year' ORDER BY matchdate DESC")));

$pages = ceil($pages/$pr);

$querystring = '';
foreach($_GET as $key => $value) {
	if($key != "page") $querystring .= "$key=$value&amp;";
}
// END PAGINATION HEAD

// BEGIN PAGINATION DISPLAY
// TODO: CHECK FOR MORE THAN 1 PAGE
if($pages > 1) {
	$display .= '<p class="pagination"><strong>Results:</strong> ';
	for($i = 1; $i <= $pages; $i++) {
		$display .= '<a '.($i == $page ? 'class="selected" ' : '');
		$display .= "href=\"?{$querystring}page=$i";
		$display .= '">'.$i.'</a> ';
	}
	$display .= '</p>';
}
// END PAGINATION DISPLAY

[/php]

Can anybody help on this one?

Can anyone help on this?

don’t know if this has been solved yet but give this a try:

[php]<?php
$page = isset($_GET[‘page’]) ? (int) $_GET[‘page’] : 1;
$max_results = get_option(‘frp_rpp’); // rows per page

// BEGIN PAGINATION HEAD
if($competition != ‘’){
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query(“SELECT COUNT(*) as Num FROM $tbl_match WHERE DATE_ADD(matchdate, INTERVAL matchtime HOUR_SECOND) <= NOW() AND competitionyear = ‘$year’ AND competition = ‘$competition’”),0);
}

if($competition == ‘’){
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query(“SELECT COUNT(*) as Num FROM $tbl_match WHERE DATE_ADD(matchdate, INTERVAL matchtime HOUR_SECOND) <= NOW() AND competitionyear = ‘$year’”),0);
}

// Figure out the total number of clientspages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

$querystring = ‘’;

foreach($_GET as $key => $value) {
if($key != “page”) $querystring .= “$key=$value&”;
}

		// Build Previous Link
		if($pages > 1){
			$prev = ($pages - 1);
				$display.=  "<a href=\"?{$querystring}page=$prev\">&lt;&lt;</a>\n ";
		}
		
		for($i = 1; $i <= $total_pages; $i++){
		 if($total_pages > 1){
				if(($pages) == $i){
					$display.=  "<span class=\"current\">$i</span>\n ";
					} else {
						$display.=  "<a href=\"?{$querystring}page=$i\">$i</a>\n ";
				}
			}
		}
		
		// Build Next Link
		if($pages < $total_pages){
			$next = ($pages + 1);
			$display.=  "<a href=\"?{$querystring}page=$next\">&gt;&gt;</a>\n";
		}

?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service