Re: Plugin: Page links for bbPress
well, I found out part of the solution myself. The code in the plugin is quite simple and it actually uses the same bbPress function that generates in-topic pagination (
And that function has several parameters on of which is
show_all – set that to false and it will not print all the links but just the links relative to the current page.
Setting the current page for the plugin is also through a parameter –
current which is set to
0. That way we get a link only to the last page but it still is better that having a long row of useless page links.
So, I cracked some more of it. I wanted to make it display links only to the firs page and to the last 2-3 pages. So the
current parameter had to be somehow dynamically set to
last page + 1 to trick the function. Here is the code I used (starting line 74 of the plugin):
$links = paginate_links(
'base' => $uri,
'format' => bb_get_option('mod_rewrite') ? '/page/%#%' : '%#%',
'total' => ceil($posts/$perPage),
'current' => ceil($posts/$perPage) + 1,
'show_all' => false,
'type' => 'array'
And it works We get links to the first page and to the last two pages.
* if you set
1 you’ll get links to pages 2,3,4 and the last page which is also usable.