Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

How to limit activity items for per page? (8 posts)

Started 1 year, 5 months ago by: Ali Erkurt

  • Profile picture of Ali Erkurt Ali Erkurt said 1 year, 5 months ago:

    Hello everyone! I want to limit my activity pages’ entries. I know there is “per_page” for that but in my activity-loop.php, there is a line like that:

    <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) ) ) : ?>

    I tried to put it like <?php if ( bp_has_activities('per_page=10', bp_ajax_querystring( 'activity' ) ) ) : ?>. It limited to 10 but ajax didn’t work. Where can I put “per_page=10″ without breaking “bp_ajax_querystring” thing. Thank you.

  • Profile picture of Ali Erkurt Ali Erkurt said 1 year, 5 months ago:

    OK, I found the solution. For those who need that here is the solution:

    Add this to your functions.php:

    function my_query_filter( $query_string ) {
    	$query_string .= '&per_page=10';
    	return $query_string;
    }
    add_filter( 'bp_dtheme_ajax_querystring', 'my_query_filter' );
  • Profile picture of Hugo Hugo said 1 year, 5 months ago:

    The function and filter is overkill really you can add to the query string but concatenating the parameter :
    bp_has_activities( bp_ajax_querystring( ‘activity’ ) . ‘per_page=10′ )

  • Profile picture of NrFive NrFive said 1 year, 3 months ago:

    @alierkurt / @hnla

    could you tell me what file needs to be edited for this?

    Tried both codes, but not getting the results expected.

  • Profile picture of Puanthanh Puanthanh said 1 year, 2 months ago:

    Check this post

    http://blogcastor.com/extend/tips-tricks/how-to-limit-activity-items-in-buddypress/

  • Profile picture of Pisanojm Pisanojm said 1 year, 2 months ago:

    @hnla

    This is something that has been bothering me… Why does this:
    <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ).'per_page=12' ) ) : ?>
    Cause the drop down search filters not to work? Is it wrong?

  • Profile picture of Pisanojm Pisanojm said 1 year, 2 months ago:

    ok… I think I worked this out… needs to be .’&per_page=12′

  • Profile picture of igeekout igeekout said 10 months, 2 weeks ago:

    Buddypress needs to do a better job of documenting things. Its like the give you a little idea but then get bored and forget to tell you the rest.