bbp_get_search_pagination_count
Return the search results pagination count.
Description
(string) bbp_get_search_pagination_count();
Returns (string)
Search pagination count
Usage
if ( !function_exists( 'bbp_get_search_pagination_count' ) ) { require_once ABSPATH . PLUGINDIR . 'bbpress/includes/search/template.php'; } // NOTICE! Understand what this does before running. $result = bbp_get_search_pagination_count();
Defined (1)
The function is defined in the following location(s).
- /includes/search/template.php
- function bbp_get_search_pagination_count() {
- $bbp =bbpress);
- // Define local variable(s)
- $retstr = '';
- // Set pagination values
- $start_num = intval( ( $bbp->search_query->paged - 1 ) * $bbp->search_query->posts_per_page ) + 1;
- $from_num = bbp_number_format( $start_num );
- $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 ) );
- $total_int = (int) $bbp->search_query->found_posts;
- $total = bbp_number_format( $total_int );
- // Single page of results
- if ( empty( $to_num ) ) {
- $retstr = sprintf( _n( 'Viewing %1$s result', 'Viewing %1$s results', $total_int, bbpress ), $total );
- // Several pages of results
- } else {
- $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 );
- }
- // Filter and return
- return apply_filters( 'bbp_get_search_pagination_count', esc_html( $retstr ) );
- }