George (@quantum_leap)

Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • @quantum_leap

    Participant

    I don’t have BuddyBoss installed. bbPress provides integration code that injects the “Forum” tab inside the group creation process. Normally:

    add_filter( 'groups_create_group_steps', function ( $steps ) {
        unset( $steps['forum'] );
        return $steps;
    } );

    or something of that sort would have solved the issue. I was wondering of bbPress injects the tab in a different way.

    I would appreciate if you could forward that to one of the devs, since you are a Mod, Robin, otherwise, thanks for the help.

    @quantum_leap

    Participant

    But the integration code resides inside bbPress. If it was core BuddyPress filters, it would be much simpler, don’t you think?

    @quantum_leap

    Participant

    For anyone that landed here from a Google search. The pagination is not working for forums set up inside BuddyPress groups. You need to copy those two files from
    \plugins\bbpress\templates\default\bbpress
    pagination-topics.php
    pagination-replies.php

    and copy them to
    \wp-content\themes\[yourchildtheme]\bbpress

    Replace the code inside pagination-topics.php to:

    <?php
    
    /**
     * Pagination for pages of topics (when viewing a forum)
     *
     * @package bbPress
     * @subpackage Theme
     */
    
    // Exit if accessed directly
    defined( 'ABSPATH' ) || exit;
    
    do_action( 'bbp_template_before_pagination_loop' );
    
    // Use bbPress setting for topics per page
    $posts_per_page = bbp_get_topics_per_page();  // Dynamically get the value from bbPress settings
    
    // Get the current page
    $paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
    
    // Set up the custom query
    $args = array(
        'post_type'      => bbp_get_topic_post_type(),
        'posts_per_page' => $posts_per_page,
        'paged'          => $paged,
        'meta_query'     => array(
            array(
                'key'   => '_bbp_forum_id',
                'value' => bbp_get_forum_id(),
            ),
        ),
    );
    
    // Run the custom query
    $forum_query = new WP_Query($args);
    
    if ($forum_query->have_posts()) :
    ?>
        <div class="bbp-pagination">
            <div class="bbp-pagination-count">
                <?php
                // Display the range of topics being viewed
                $start = ($paged - 1) * $posts_per_page + 1;
                $end = min($paged * $posts_per_page, $forum_query->found_posts);
                echo sprintf(__('Viewing %1$s to %2$s (of %3$s topics)'), $start, $end, $forum_query->found_posts);
                ?>
            </div>
            <div class="bbp-pagination-links">
                <?php
                // Generate the pagination links
                echo paginate_links(array(
                    'total'   => $forum_query->max_num_pages,
                    'current' => $paged,
                    'format'  => '?paged=%#%',
                    'add_args' => false,
                    'prev_text' => __('« Prev'),
                    'next_text' => __('Next »'),
                ));
                ?>
            </div>
        </div>
    <?php
    else :
        echo '<p>No topics found.</p>';
    endif;
    
    // Reset post data
    wp_reset_postdata();
    
    do_action('bbp_template_after_pagination_loop');
    ?>
    

    Replace the code inside pagination-replies.php to:

    <?php
    
    /**
     * Pagination for pages of replies (when viewing a topic)
     *
     * @package bbPress
     * @subpackage Theme
     */
    
    // Exit if accessed directly
    defined( 'ABSPATH' ) || exit;
    
    do_action( 'bbp_template_before_pagination_loop' );
    
    // Use bbPress setting for replies per page
    $posts_per_page = bbp_get_replies_per_page();  // Dynamically get the value from bbPress settings
    
    // Get the current page
    $paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
    
    // Set up the custom query
    $args = array(
        'post_type'      => bbp_get_reply_post_type(),
        'posts_per_page' => $posts_per_page,
        'paged'          => $paged,
        'meta_query'     => array(
            array(
                'key'   => '_bbp_topic_id',
                'value' => bbp_get_topic_id(),
            ),
        ),
    );
    
    // Run the custom query
    $replies_query = new WP_Query($args);
    
    if ($replies_query->have_posts()) :
    ?>
        <div class="bbp-pagination">
            <div class="bbp-pagination-count">
                <?php
                // Display the range of replies being viewed
                $start = ($paged - 1) * $posts_per_page + 1;
                $end = min($paged * $posts_per_page, $replies_query->found_posts);
                echo sprintf(__('Viewing %1$s to %2$s (of %3$s replies)'), $start, $end, $replies_query->found_posts);
                ?>
            </div>
            <div class="bbp-pagination-links">
                <?php
                // Generate the pagination links
                echo paginate_links(array(
                    'total'   => $replies_query->max_num_pages,
                    'current' => $paged,
                    'format'  => '?paged=%#%',
                    'add_args' => false,
                    'prev_text' => __('« Prev'),
                    'next_text' => __('Next »'),
                ));
                ?>
            </div>
        </div>
    <?php
    else :
        echo '<p>No replies found.</p>';
    endif;
    
    // Reset post data
    wp_reset_postdata();
    
    do_action('bbp_template_after_pagination_loop');
    ?>
    
Viewing 3 replies - 1 through 3 (of 3 total)