bbp_get_forum_pagination_count

Return the pagination count.

Description

(string) bbp_get_forum_pagination_count(); 

Returns (string)

Forum Pagintion count


Usage

  1. if ( !function_exists( 'bbp_get_forum_pagination_count' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bbp_get_forum_pagination_count(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/topics/template.php  
  1. function bbp_get_forum_pagination_count() { 
  2. $bbp =bbpress); 
  3.  
  4. if ( empty( $bbp->topic_query ) ) 
  5. return false; 
  6.  
  7. // Set pagination values 
  8. $start_num = intval( ( $bbp->topic_query->paged - 1 ) * $bbp->topic_query->posts_per_page ) + 1; 
  9. $from_num = bbp_number_format( $start_num ); 
  10. $to_num = bbp_number_format( ( $start_num + ( $bbp->topic_query->posts_per_page - 1 ) > $bbp->topic_query->found_posts ) ? $bbp->topic_query->found_posts : $start_num + ( $bbp->topic_query->posts_per_page - 1 ) ); 
  11. $total_int = (int) !empty( $bbp->topic_query->found_posts ) ? $bbp->topic_query->found_posts : $bbp->topic_query->post_count; 
  12. $total = bbp_number_format( $total_int ); 
  13.  
  14. // Several topics in a forum with a single page 
  15. if ( empty( $to_num ) ) { 
  16. $retstr = sprintf( _n( 'Viewing %1$s topic', 'Viewing %1$s topics', $total_int, bbpress ), $total ); 
  17.  
  18. // Several topics in a forum with several pages 
  19. } else { 
  20. $retstr = sprintf( _n( 'Viewing topic %2$s (of %4$s total)', 'Viewing %1$s topics - %2$s through %3$s (of %4$s total)', $total_int, bbpress ), $bbp->topic_query->post_count, $from_num, $to_num, $total ); 
  21.  
  22. // Filter and return 
  23. return apply_filters( 'bbp_get_forum_pagination_count', esc_html( $retstr ) );