bbp_get_search_pagination_count

Return the search results pagination count.

Description

(string) bbp_get_search_pagination_count(); 

Returns (string)

Search pagination count


Usage

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

Defined (1)

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

/includes/search/template.php  
  1. function bbp_get_search_pagination_count() { 
  2. $bbp =bbpress); 
  3.  
  4. // Define local variable(s) 
  5. $retstr = ''; 
  6.  
  7. // Set pagination values 
  8. $start_num = intval( ( $bbp->search_query->paged - 1 ) * $bbp->search_query->posts_per_page ) + 1; 
  9. $from_num = bbp_number_format( $start_num ); 
  10. $to_num = bbp_number_format( ( $start_num + ( $bbp->search_query->posts_per_page - 1 ) > $bbp->search_query->found_posts ) ? $bbp->search_query->found_posts : $start_num + ( $bbp->search_query->posts_per_page - 1 ) ); 
  11. $total_int = (int) $bbp->search_query->found_posts; 
  12. $total = bbp_number_format( $total_int ); 
  13.  
  14. // Single page of results 
  15. if ( empty( $to_num ) ) { 
  16. $retstr = sprintf( _n( 'Viewing %1$s result', 'Viewing %1$s results', $total_int, bbpress ), $total ); 
  17.  
  18. // Several pages of results 
  19. } else { 
  20. $retstr = sprintf( _n( 'Viewing %2$s results (of %4$s total)', 'Viewing %1$s results - %2$s through %3$s (of %4$s total)', $bbp->search_query->post_count, bbpress ), $bbp->search_query->post_count, $from_num, $to_num, $total ); 
  21.  
  22.  
  23. // Filter and return 
  24. return apply_filters( 'bbp_get_search_pagination_count', esc_html( $retstr ) );