#5370 closed defect (bug) (fixed)
bp_legacy_theme_ajax_querystring per_page stopped working
Reported by: | modemlooper | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 1.9.1 |
Component: | Core | Keywords: | |
Cc: |
Description
Using the code below no longer works right. It only shows two items but when clicking pagination on activity it returns page 1 results and loads them below. On members loops It fades and then replaces itself with page 1 results.
Using per_page in a template file has same results. Changing per_page in bp-members-template.php > bp_has_members() works like it should.
function my_bp_loop_querystring( $query_string, $object ) { $query_string = 'per_page=2'; return $query_string; } add_filter( 'bp_legacy_theme_ajax_querystring', 'my_bp_loop_querystring', 20, 2 );
Change History (5)
#2
@
11 years ago
- Keywords reporter-feedback added; dev-feedback removed
OK, looks like your filter is not correctly written. You're wiping out the entire $query_string, which means that the pagination arguments on subsequent pages are getting wiped out too. You have to add your param, not overwrite the whole thing:
function my_bp_loop_querystring( $query_string, $object ) { if ( ! empty( $query_string ) ) { $query_string .= '&'; } $query_string .= 'per_page=2'; return $query_string; } add_action( 'bp_legacy_theme_ajax_querystring', 'my_bp_loop_querystring', 20, 2 );
I know this isn't the most elegant thing in the world, but it's how the filter has always worked. (We should come up with something a little easier to deal with in the future.)
modemlooper - Can you give details about when this actually did work? I just tested on 1.7 and 1.8 and it doesn't seem to work there either.
I'll keep digging for root causes.