Pagination issue in DIVs

Hi,
I’m having an issue with some PHP code for my wordpress sidebar. It is a secondary loop that displays recent posts with pagination. I’ve got the basics working (ie, it pulls the content, and paginates)… but, I want to modify things ever so slightly to try and get the pagination numbers/links sitting in their own div so they don’t scroll with the main content. I thought i had it figured out, but, no such luck. as soon as I move things to the new div, the pagination/navigation stops functioning.Does anyone see a simple way around this?

Line 27 is where I tried closing my scrolling DIV and Line 28 is opening a new one for the pagination. It works… but it seems to totally kill the connection between the posts and the paging. It still shows the numbers, and even shows the links in the source code… but, nothing in the new div is clickable.

Here is code.

[php]

Latest Posts

<?php $sql = "SELECT p.* from $wpdb->posts p WHERE p.post_type = 'post' AND p.post_status = 'publish' ORDER by p.post_date DESC"; $mypages = $wpdb->get_results($sql); if ($mypages) : $limit = 5; // The number of posts per page $range = 3; // The number of page links to show in the middle $mypage = (isset($_GET['mypage'])) ? $mypage = $_GET['mypage'] : 1; $start = ($mypage - 1) * $limit; for ($i=$start;$i<($start + $limit);++$i) { if ($i < sizeof($mypages)) { // Process each element of the result array here $post = $mypages[$i]; setup_postdata($post); echo get_the_post_thumbnail($page->ID, 'thumbnail'); echo '

';the_title();echo '

'; echo the_excerpt(); echo'read more...'; } } echo '
'; // End Scrollables echo '
'; // Start Pagination echo _mam_paginate(sizeof($mypages),$limit,$range); else: echo '

Sorry, There are no Pages to list

'; endif;?>
<?php function _mam_paginate($numrows,$limit=10,$range=7) { $pagelinks = "
"; $currpage = $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']; if ($numrows > $limit) { if(isset($_GET['mypage'])){ $mypage = $_GET['mypage']; } else { $mypage = 1; } $currpage = $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']; $currpage = str_replace("&mypage=".$mypage,"",$currpage); // Use this for non-pretty permalink $currpage = str_replace("?mypage=".$mypage,"",$currpage); // Use this for pretty permalink if($mypage == 1){ $pagelinks .= "&laquo PREV "; }else{ $pageprev = $mypage - 1; $pagelinks .= "&laquo PREV "; } $numofpages = ceil($numrows / $limit); if ($range == "" or $range == 0) $range = 7; $lrange = max(1,$mypage-(($range-1)/2)); $rrange = min($numofpages,$mypage+(($range-1)/2)); if (($rrange - $lrange) < ($range - 1)) { if ($lrange == 1) { $rrange = min($lrange + ($range-1), $numofpages); } else { $lrange = max($rrange - ($range-1), 0); } } if ($lrange > 1) { $pagelinks .= " [1] "; if ($lrange > 2) $pagelinks .= " ... "; } else { $pagelinks .= "  "; } for($i = 1; $i <= $numofpages; $i++){ if ($i == $mypage) { $pagelinks .= " [$i] "; } else { if ($lrange <= $i and $i <= $rrange) { $pagelinks .= " [" . $i . "] "; } } } if ($rrange < $numofpages) { if ($rrange < $numofpages - 1) $pagelinks .= " ... "; $pagelinks .= " [" . $numofpages . "] "; } else { $pagelinks .= "  "; } if(($numrows - ($limit * $mypage)) > 0){ $pagenext = $mypage + 1; $pagelinks .= " NEXT »"; } else { $pagelinks .= " NEXT »"; } } $pagelinks .= "
"; return $pagelinks; } ?>

[/php]

If it matters, I’m just checking the site locally using MAMP at the moment.

Thank you!

Sponsor our Newsletter | Privacy Policy | Terms of Service