Paging for wp_list_bookmakrs
-
Hello,
I’m wondering if there is a way to setup paging or pagination on bookmarks/links.
I’d like to show 20 or so bookmarks/links per page.Here is the page where I would like to get paging going on.
http://www.terminaldusk.com/discog/Thanks in advance!
-
Here is a link to a module I wrote to paginate a custom archive list.
The technique should be very similar.
I can get the pagination working for posts but I’m not sure how to tell it to pull from the bookmarks, can you help?
This is what I was using before:
<?php wp_list_bookmarks('title_li=&categorize=0&category=8&before=<li>&after=</p></li>&show_images=1&orderby=name&order=desc&show_description=1&between=<p class="discogNavTitle">'); ?>Copy the module from the link above, then replace this:
<?php $args = array('type' => 'alpha', 'echo' => 0, 'after' => '~'); $archivestring = wp_get_archives($args); $archives = preg_split('/[~]/',$archivestring); if ($archives) : $limit = 4; if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } $start = ($page - 1) * $limit; $range = 5; echo '<h2></h2>'; echo '<ul>'; for ($i=$start;$i<($start + $limit);++$i) { if ($i < sizeof($archives)) { echo $archives[$i]; } } echo '<br /><br />'; echo _gur_paginate(sizeof($archives),$limit,$range); echo '</li></ul>'; else: echo '<h2></h2>'; echo 'There are no Archives to list'; endif;?>with this:
<?php $bookmarks = wp_list_bookmarks('echo=0&title_li=&categorize=0&category=8&before=<li>&after=</p></li>&show_images=1&orderby=name&order=desc&show_description=1&between=<p class="discogNavTitle">'); if ($bookmarks) : $limit = 20; if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } $start = ($page - 1) * $limit; $range = 5; echo '<ul>'; for ($i=$start;$i<($start + $limit);++$i) { if ($i < sizeof($bookmarks)) { echo $bookmarks[$i]; } } echo '</li></ul>'; echo '<br /><br />'; echo _gur_paginate(sizeof($bookmarks),$limit,$range); else: echo '<h2>There are no Bookmarks to list</h2>'; endif;?>I have this pasted in my page but paging did not work.
<?php $bookmarks = wp_list_bookmarks('orderby=name&category=8&order=DESC'); if ($bookmarks) : $limit = 20; if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } $start = ($page - 1) * $limit; $range = 5; echo '<ul>'; for ($i=$start;$i<($start + $limit);++$i) { if ($i < sizeof($bookmarks)) { echo $bookmarks[$i]; } } echo '</li></ul>'; echo '<br /><br />'; echo _gur_paginate(sizeof($bookmarks),$limit,$range); else: echo '<h2>There are no Bookmarks to list</h2>'; endif;?> <?php function _gur_paginate($numrows,$limit=10,$range=7) { $pagelinks = "<div class=\"pagelinks\">"; if(isset($_GET['page'])){ $page = $_GET['page']; } else { $page = 1; } // If query_string exists, use &page=, else use ?page= . $currpage = $_SERVER['REQUEST_URI']; $qstring = preg_replace('/page=\d+/','',$_SERVER['QUERY_STRING']); // Get rid of previous page= if ($qstring) { $paramsep = '&'; } else { $paramsep = '?'; } if ($numrows > $limit) { $currpage = str_replace("&page=".$page,"",$currpage); // Use this for non-pretty permalink $currpage = str_replace("?page=".$page,"",$currpage); // Use this for pretty permalink if($page == 1){ $pagelinks .= "<span class=\"pageprevdead\">« PREV </span>"; }else{ $pageprev = $page - 1; $pagelinks .= "<a class=\"pageprevlink\" href=\"" . $currpage . "{$paramsep}page=" . $pageprev . "\">« PREV </a>"; } $numofpages = ceil($numrows / $limit); if ($range == "" or $range == 0) $range = 7; $lrange = max(1,$page-(($range-1)/2)); $rrange = min($numofpages,$page+(($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 .= "<a class=\"pagenumlink\" " . "href=\"" . $currpage . "{$paramsep}page=" . 1 . "\"> [1] </a>"; if ($lrange > 2) $pagelinks .= " ... "; } else { $pagelinks .= " "; } for($i = 1; $i <= $numofpages; $i++){ if ($i == $page) { $pagelinks .= "<span class=\"pagenumon\"> [$i] </span>"; } else { if ($lrange <= $i and $i <= $rrange) { $pagelinks .= "<a class=\"pagenumlink\" " . "href=\"" . $currpage . "{$paramsep}page=" . $i . "\"> [" . $i . "] </a>"; } } } if ($rrange < $numofpages) { if ($rrange < $numofpages - 1) $pagelinks .= " ... "; $pagelinks .= "<a class=\"pagenumlink\" " . "href=\"" . $currpage . "{$paramsep}page=" . $numofpages . "\"> [" . $numofpages . "] </a>"; } else { $pagelinks .= " "; } if(($numrows - ($limit * $page)) > 0){ $pagenext = $page + 1; $pagelinks .= "<a class=\"pagenextlink\" href=\"" . $currpage . "{$paramsep}page=" . $pagenext . "\"> NEXT »</a>"; } else { $pagelinks .= "<span class=\"pagenextdead\"> NEXT »</span>"; } } $pagelinks .= "</div>"; return $pagelinks; } ?>I can’t tell if the code is even getting called. There is too much to paste into these messages, so please paste the whole file into wordpress.pastebin.ca, and post a link to it here.
The topic ‘Paging for wp_list_bookmakrs’ is closed to new replies.