Group Admins

BuddyPress Troubleshooting and Support

Public Group active 1 year, 3 months ago ago

BuddyPress support from our community

Limit # of items in the Activity Stream Loop?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #1373
    Darin Roman

    Does anyone know how to limit the number of initially loaded items in the activity stream? I have a heavy media sharing community which causes a slow page load on the activity stream. I’d like to limit the initially displayed entries to 5-10 from the default value of 20.

    The BuddyPress Codex shares some info but does not go into great detail and my PHP skills are still a bit weak.

    The parameter I am looking to use is ‘per_page’.

    Only one filtering example is shown and I cannot figure out how one would take such an example, use the desired parameter and integrate it with the standard loop.

    Any help would be appreciated.



    @Darin– We have a custom activity stream on the front page of this site. Here’s some sample code. Essentially you need to write your own loop.

    There may be an easier way with BP 1.5… This code was written before 1.5. was released.

    Darin Roman


    Thank you for this! This code snippet is definitely heading in the right direction. I works well for custom loops of latest entries as long as you do not need to load more, as on the main activity stream page. This is where I am trying to limit the output.

    I’ll need to play with it a bit to get working the way I’d like. When I pass the arguments ( ‘per_page=5&page=1’ ) it returns only 5 items as expected, however, it returns the same 5 items every time I click ‘Load More’. I get the same result even if I remove the ‘page=1’ parameter since that is a default value.

    I am working with the latest BP 1.5.4 so I am not sure if there were any significant changes to the activity since. I’ll keep searching and experimenting.

    I appreciate the feedback and help!

    Darin Roman


    Update: I received a simple answer on the BP forums.

    Just in case anyone wants to limit their main Activity Stream Page, simply edit this line in your theme’s activity/activity-loop.php file:

    if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ) . ‘&per_page=5’ ) ) :

    BTW: Are there any tags enabled here to display code?


    @Darin– A small correction. Do NOT edit the main BuddyPress theme files.
    -Make a child theme for BP
    -copy the file activity/activity-loop.php and place it in your child theme, in a subdirectory called “activity”.
    -Edit THAT file.

    Yes, wrap your code in

    Darin Roman


    I am editing this awesome WP/BP theme (framework) Salutation, which includes customized copies of all BP default templates and folder structure, therefore, I am not touching the BP default theme or any core files.

    It is certainly something important to remember, thanks for mentioning it.

    I’ve spent a great deal of time figuring things out, which is great and helps my understanding. BuddyPress is a good theme development challenge. I definitely plan to learn PHP properly though, to speed up development time.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.