bbp_get_topic_pagination( array $args = array() )
Returns pagination links of a topic within the topic loop
Description Description
Parameters Parameters
- $args
-
(Optional) This function supports these arguments: - topic_id: Topic id - before: Before the links - after: After the links
Default value: array()
Return Return
(string) Pagination links
Source Source
File: includes/topics/template.php
function bbp_get_topic_pagination( $args = array() ) { // Bail if threading replies if ( bbp_thread_replies() ) { return; } // Parse arguments against default values $r = bbp_parse_args( $args, array( 'topic_id' => bbp_get_topic_id(), 'before' => '<span class="bbp-topic-pagination">', 'after' => '</span>', ), 'get_topic_pagination' ); // Slug must be checked for topics that have never been approved/published $has_slug = bbp_get_topic( $r['topic_id'] )->post_name; // If pretty permalinks are enabled, make our pagination pretty $base = ! empty( $has_slug ) && bbp_use_pretty_urls() && ! bbp_is_topic_pending( $r['topic_id'] ) ? trailingslashit( get_permalink( $r['topic_id'] ) ) . user_trailingslashit( bbp_get_paged_slug() . '/%#%/' ) : add_query_arg( 'paged', '%#%', get_permalink( $r['topic_id'] ) ); // Get total and add 1 if topic is included in the reply loop $total = bbp_get_topic_reply_count( $r['topic_id'], true ); // Bump if topic is in loop if ( ! bbp_show_lead_topic() ) { $total++; } // Total for pagination boundaries $total_pages = ceil( $total / bbp_get_replies_per_page() ); // Maybe add view-all args $add_args = bbp_get_view_all( 'edit_others_replies' ) ? array( 'view' => 'all' ) : false; // Pagination settings with filter $bbp_topic_pagination = apply_filters( 'bbp_get_topic_pagination', array( 'base' => $base, 'total' => $total_pages, 'current' => 0, 'prev_next' => false, 'mid_size' => 2, 'end_size' => 2, 'add_args' => $add_args ) ); // Add pagination to query object $pagination_links = bbp_paginate_links( $bbp_topic_pagination ); // Maybe add before and after to pagination links if ( ! empty( $pagination_links ) ) { $pagination_links = $r['before'] . $pagination_links . $r['after']; } // Filter & return return apply_filters( 'bbp_get_topic_pagination', $pagination_links, $args ); }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |