Jump to content

Wordpress Plugin Pagination Code


Cyberdave

Recommended Posts

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:

$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&";
}
// 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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.