Skip to content

Instantly share code, notes, and snippets.

@imath
Created December 30, 2023 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imath/24fdfa1b8625477e93c0daa0d90b2a44 to your computer and use it in GitHub Desktop.
Save imath/24fdfa1b8625477e93c0daa0d90b2a44 to your computer and use it in GitHub Desktop.
Fix bbPress pagination in BP Member's forum page
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* bbPress should include such an action into its `src/includes/extend/buddypress/members.php` file.
*/
function fix_bbpress_member_pagination( &$query ) {
if ( bp_is_user() && bp_is_current_component( 'forums' ) ) {
$action_variables = (array) bp_action_variables();
if ( function_exists( 'bbp_get_paged_slug' ) && bbp_get_paged_slug() === bp_action_variable( 0 ) ) {
$query->set( 'paged', (int) bp_action_variable( 1 ) );
}
}
}
add_action( 'bp_members_parse_query', 'fix_bbpress_member_pagination' );
@dcavins
Copy link

dcavins commented Dec 30, 2023

We found an issue like this is BP Docs, too, where the pagination of our custom component had stopped working, but I think it had stopped working by BP v11.

@imath
Copy link
Author

imath commented Dec 30, 2023

Interesting, were you also using the paged query var ?

@dcavins
Copy link

dcavins commented Dec 30, 2023

Yep! Something that used to work in the Docs plugin stopped working some time ago--I'm not really even sure when. Our fix was similar: Look specifically for the action args and set the page: boonebgorges/buddypress-docs@b1f39bb

@LordSimal
Copy link

This problem also exists on group pages so I had to adjust the code slightly for my own usecase. But everyone should be able to do this depending on their usecase.

@imath
Copy link
Author

imath commented Feb 13, 2024

FYI this will be fixed in BP Classic v1.4.0, see buddypress/bp-classic#44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment