bbp_get_topic_pagination_count()

Return the topic pagination count

Description

Return

(string) Topic pagination count

Source

File: bp-forums/replies/template.php

2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
function bbp_get_topic_pagination_count() {
    $bbp = bbpress();
 
    // Define local variable(s)
    $retstr = '';
 
    // Set pagination values
    $start_num = intval( ( $bbp->reply_query->paged - 1 ) * $bbp->reply_query->posts_per_page ) + 1;
    $from_num  = bbp_number_format( $start_num );
    $to_num    = bbp_number_format( ( $start_num + ( $bbp->reply_query->posts_per_page - 1 ) > $bbp->reply_query->found_posts ) ? $bbp->reply_query->found_posts : $start_num + ( $bbp->reply_query->posts_per_page - 1 ) );
    $total_int = (int) $bbp->reply_query->found_posts;
    $total     = bbp_number_format( $total_int );
 
    // We are threading replies
    if ( bbp_thread_replies() && bbp_is_single_topic() ) {
        return;
        $walker  = new BBP_Walker_Reply;
        $threads = (int) $walker->get_number_of_root_elements( $bbp->reply_query->posts );
 
        // Adjust for topic
        $threads--;
        $retstr  = sprintf( _n( 'Viewing %1$s reply thread', 'Viewing %1$s reply threads', $threads, 'buddyboss' ), bbp_number_format( $threads ) );
 
    // We are not including the lead topic
    } elseif ( bbp_show_lead_topic() ) {
 
        // Several replies in a topic with a single page
        if ( empty( $to_num ) ) {
            $retstr = sprintf( _n( 'Viewing %1$s reply', 'Viewing %1$s replies', $total_int, 'buddyboss' ), $total );
 
        // Several replies in a topic with several pages
        } else {
            $retstr = sprintf( _n( 'Viewing %2$s of %4$s replies', 'Viewing %2$s - %3$s of %4$s replies', $bbp->reply_query->post_count, 'buddyboss' ), $bbp->reply_query->post_count, $from_num, $to_num, $total );
        }
 
    // We are including the lead topic
    } else {
 
        // Several posts in a topic with a single page
        if ( empty( $to_num ) ) {
            $retstr = sprintf( _n( 'Viewing %1$s post', 'Viewing %1$s posts', $total_int, 'buddyboss' ), $total );
 
        // Several posts in a topic with several pages
        } else {
            $retstr = sprintf( _n( 'Viewing %2$s of %4$s posts', 'Viewing %2$s - %3$s of %4$s posts', $bbp->reply_query->post_count, 'buddyboss' ), $bbp->reply_query->post_count, $from_num, $to_num, $total );
        }
    }
 
    // Filter and return
    return apply_filters( 'bbp_get_topic_pagination_count', esc_html( $retstr ) );
}

Changelog

Changelog
Version Description
bbPress (r2519) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.