Info
- 5 posts
- 2 voices
- Started 3 years ago by _ck_
- Latest reply from TrishaM
- This topic is not a support question
here's how to add front page pagination (page numbers)
-
- Posted 3 years ago #
update: I've now included this functionality in the topics-per-page plugin so use that instead which is maintained and not this mini-plugin which will not work properly with 1.0a
Here's something I had made a mental note of quite awhile ago but forgot to do, add pagination to the front-page for the latest discussions. You can see a demo near the bottom of http://bbshowcase.org/forums/
(the following two functions are included in the 0.0.4 version of topics-page-page plugin, so don't use them if you have that)
add_filter('get_latest_topics_limit','front_page_pagination',999); function front_page_pagination($limit="") { global $page; if (is_front() && $page>1) {$limit.=" OFFSET ".($page-1)*bb_get_option('page_topics');} return $limit; } function front_page_pages() { global $page, $bbdb; echo get_page_number_links( $page, $bbdb->get_var("SELECT SUM(topics) FROM $bbdb->forums")); }
1. add to yourfront-page.phptemplate
<div class="nav"><?php front_page_pages(); ?></div>
AFTER
<?php endforeach; endif; // $topics ?> </table>
2. If you use rewrite slugs you MUST add the following rule to your.htaccessfile
RewriteRule ^page/([0-9]+)/?$ /forums/?page= [L,QSA]anywhere before
</IfModule>
where/forums/is the path to your bbpress install. -
- Posted 3 years ago #
Also, if you'd like to dynamically add some text to the left (or even the right) of the page links without hacking all your templates, you can use this trick:
// add "pages:" to page links function text_topic_pages( $text ) { if ($text) {$text="pages: ".$text;} return $text; } add_filter('topic_pages', 'text_topic_pages'); add_filter('forum_pages', 'text_topic_pages');
This way the word "pages:" appears before the page number links only if there actually are any pages for the results. -
- Posted 3 years ago #
Excellent tip on adding the text "Pages" - this is a great plugin and works perfectly.
-
- Posted 3 years ago #
Hmmm found a problem but not sure if it's related to this pagination or not....
When I am on my Front Page and click on any of the other pages numbers (2, 3, Next>>, etc) I get this error:
Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 0 in /[myURL]/Forum/bb-includes/template-functions.php on line 925
Any ideas?
-
- Posted 3 years ago #
By the way, this only happens on my front-page.php. When I use the pagination on my forum pages I don't get the error......
Started new topic:
http://bbpress.org/forums/topic/topics-per-page-plugin-new-problem -
You must log in to post.