I’m using Blog Categories For Groups (BCG) and I want to setup infinite scrolling for the posts on the BuddyPress group page.
BuddyBoss has infinite scrolling pagnation, so I’m trying to use that inside a BCG
posts.php
template.The infinite scrolling pagnation in the template below works, but instead of outputting just the posts it wraps the entire thing in another group page.
<?php /** * Blog Categories for Groups- Posts list template. */ ?> <?php $q = new WP_Query( bcg_get_query() ); ?> <?php if ( $q->have_posts() ) : ?> <?php do_action( 'bp_before_group_blog_content' ); ?> <?php do_action( 'bp_before_group_blog_list' ); ?> <div class="post-grid bb-standard"> <?php bcg_loop_start();// please do not remove it. while ( $q->have_posts() ) : $q->the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <div class="post-content"> <h2 class="posttitle"> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'blog-categories-for-groups' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a> </h2> </div> </div> <?php endwhile; ?> <?php do_action( 'bp_after_group_blog_content' ); bcg_loop_end();// please do not remove it. ?> </div> <?php buddyboss_pagination(); ?> <?php else : ?> <div id="message" class="info"> <p><?php _e( 'This group has no blog posts.', 'blog-categories-for-groups' ); ?></p> </div> <?php endif; ?>
This is the pluggable function I’m using to add infinite scroll pagnation support for BCG. Instead of working with the
global $wp_query
I’m checking if it’s a Buddypress group page and then passing in yourbcg_get_query()
.//Add BCG into buddyboss pagnation if ( ! function_exists( 'buddyboss_pagination' ) ) { /** * Custom Pagination */ function buddyboss_pagination() { global $paged; if ( bp_is_groups_component() ) { $wp_query = new WP_Query( bcg_get_query() ); //Changes the query if it's a BuddyPress group } else { global $wp_query; } $max_page = 0; if ( ! $max_page ) { $max_page = $wp_query->max_num_pages; } if ( ! $paged ) { $paged = 1; } $nextpage = intval( $paged ) + 1; if ( is_front_page() || is_home() ) { $template = 'home'; } elseif ( is_category() ) { $template = 'category'; } elseif ( is_search() ) { $template = 'search'; } else { $template = 'archive'; } $class = ( true ) ? ' post-infinite-scroll' : ''; $label = __( 'Load More', 'buddyboss-theme' ); if ( ! is_single() && ( $nextpage <= $max_page ) ) { $attr = 'data-page=' . $nextpage . ' data-template=' . $template; echo '<div class="bb-pagination pagination-below"><a class="button-load-more-posts' . $class . '" href="' . next_posts( $max_page, false ) . "\" $attr>" . $label . '</a></div>'; } } }
How can I make the it output just the posts, not the entire group page each time it loads?
Hi Hob Nob,
Please contact BuddyBoss support for the same.Here is what I am guessing.
The infinite scroll they have implemented is by loading the complete next page via ajax and then extracting the posts section and appending to current page.
That part is failing for the Blog Categories for Groups. They may be able to provide you some css class or id to assist the theme in identifying post section.
Regards
BrajeshYou are welcome.
I am glad you were able to resolve it.Regards
Brajesh
The topic ‘ [Resolved] Adding BuddyBoss infinite scroll to group pages (Blog Categories For Groups)’ is closed to new replies.