Reply To: Help filtering my custom activity pages with parse_args
Thanks Henry. I’ve got more info on this to help the core team fix this issue.
I think all WordPress conditionals are not working correctly inside the bp_after_has_activities_parse_args filter. Only BuddyPress conditionals are working inside it.
I also have custom member pages too using bp_after_has_members_parse_args, but WordPress conditionals inside that are all working fine, example:
// filter member pages
function cm_members_filter( $retval ) {
if ( is_page('custom-page-3') ) {
$retval['per_page'] = 1;
}
if ( is_page('custom-page-4') ) {
$retval['per_page'] = 5;
}
if ( is_search() ) {
$retval['per_page'] = 3;
}
return $retval;
}
add_filter( 'bp_after_has_members_parse_args', 'cm_members_filter' );
It is just the activity parse args that is having problems with WordPress conditionals. I can provide further info to help figure out why WordPress conditionals don’t work correctly inside bp_after_has_activities_parse_args, it has something to do with the way ajax is used on the load more button to load more items:
If I remove activity ajax features by removing <div class=”activity”></div> or by removing bp-templates/bp-legacy/js/buddypress.min.js. The load more button now works like a pagination next page button (similar to the members directory pagination). This makes the WordPress conditionals work fine and all my custom activity pages are now filtering correctly.
So to conclude, WordPress conditionals are working OK inside bp_after_has_members_parse_args, but they are not working correctly inside bp_after_has_activities_parse_args unless the activity ajax is removed.