Skip to content

Instantly share code, notes, and snippets.

@imath
Created December 30, 2023 10:31
Show Gist options
  • Select an option

  • Save imath/24fdfa1b8625477e93c0daa0d90b2a44 to your computer and use it in GitHub Desktop.

Select an option

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

dcavins commented Dec 30, 2023

Copy link
Copy Markdown

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

imath commented Dec 30, 2023

Copy link
Copy Markdown
Author

Interesting, were you also using the paged query var ?

@dcavins

dcavins commented Dec 30, 2023

Copy link
Copy Markdown

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
Copy Markdown

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

imath commented Feb 13, 2024

Copy link
Copy Markdown
Author

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