Fix bbPress pagination


/ Published in: PHP
Save to your folder(s)

For some reason bbPress seems to use the base domain name (rather than the current forum) as the URL to which it appends /page/2 (for example) in its pagination. This seems to fix it.


Copy this code and paste it in your HTML
  1. function fix_pagination($args) {
  2. global $wp_query,$bbp;
  3. $max_pages = $bbp->topic_query->max_num_pages;
  4. $page = $bbp->topic_query->paged;
  5. $mybase = get_permalink($wp_query->post->ID);
  6. $args = array (
  7. 'base' => $mybase.$wp_rewrite->pagination_base.'/%#%/',
  8. 'format' => '',
  9. 'total' => $max_pages,
  10. 'current' => $page,
  11. 'prev_text' => '←',
  12. 'next_text' => '→',
  13. 'mid_size' => 1
  14. );
  15. return $args;
  16. }
  17. add_filter('bbp_topic_pagination','fix_pagination');

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.