Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to add (\'per_page=35\') without messing up \"Load More\" link

  • @liesl1698

    Participant

    So I was told to have this <?php if ( bp_has_activities (‘per_page=35’) ) : ?> in order to change the amount of posts that show up in the activity stream (35 being the number I decided to use)… But the issue is that in my activity-loop.php I had this: <?php if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ) ) ) : ?> and by removing the ( bp_ajax_querystring( ‘activity’ ) ) part and replacing it with (‘per_page=35’) it messed up the “Load More” link. It would show the same posts over and over (each time you clicked on “Load More”).

    So my question is how do I put (‘per_page=35’) into the bp_has_activities function without removing the other code?

Viewing 18 replies - 1 through 18 (of 18 total)
  • @chouf1

    Participant

    hi,

    did you tried ‘max=35’ ?

    @liesl1698

    Participant

    No.. where am I supposed to put that? Sorry, I’m not really a developer and I don’t want to mess anything up. Could you be more specific please?

    @liesl1698

    Participant

    I tried using that but it didn’t do anything. ‘per_page=35’ works but what I’m trying to do is put it into:

    <?php if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ) ) ) : ?> because if i replace it with the bp_ajax_querystring( ‘activity’ ) part, the “Load More” thing won’t work anymore.

    @chouf1

    Participant

    <?php if ( bp_has_activities ( ‘max=35’ ) ) : ?>

    @liesl1698

    Participant

    That didn’t work. The problem is that I have this:

    <?php if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ) ) ) : ?> which makes the “Load More” link work. I am trying to ADD ‘per_page=35’ (which I know works when put this way: <?php if ( bp_has_activities ( ‘per_page=35’ ) ) : ?> but I need to keep, not replace, the bp_ajax_querystring part). How do I do that?

    @boonebgorges

    Keymaster

    You’ll have to filter the output of bp_ajax_querystring. See some of the discussion on this page: https://buddypress.org/forums/topic/how-can-i-set-show-newblogposts-as-default-on-acitivity-stream

    @liesl1698

    Participant

    I looked at it but the code on there seemed to be for something else so I’m not really sure what you mean… :/

    @boonebgorges

    Keymaster

    It is indeed for something else, but it gives you the strategy. A function like

    function my_custom_query_filter( $query_string ) {
    $query_string .= '&per_page=35';

    return $query_string;
    }
    add_filter( 'bp_dtheme_ajax_querystring', 'my_custom_query_filter' );

    does something pretty close to what you want.

    @liesl1698

    Participant

    Oh I see. Where would I have to put that?

    @boonebgorges

    Keymaster

    Either into your child theme’s functions.php file, or into a file in your plugin directory called bp-custom.php

    @liesl1698

    Participant

    That worked. Thank you SO much!!!

    @xrun

    Member

    @boonebgorges I did this, and set the limit to 5 while testing. It adds a “load more” link at the bottom of that short list, but when I click it nothing happens, nothing more is shown.
    What I did was to copy and put this into my bp-custom.php :

    function my_custom_query_filter( $query_string ) {
    $query_string .= ‘&per_page=35’;

    return $query_string;
    }
    add_filter( ‘bp_dtheme_ajax_querystring’, ‘my_custom_query_filter’ );

    @boonebgorges

    Keymaster

    @xrun Does the Load More link work without that filter in bp-custom.php? Sounds like it might be a javascript issue unrelated to the custom function.

    @starepod

    Member

    I am doing something very similar to this using @boonebgorges function where i am passing a bunch of user ids for the ‘include’ argument and setting ‘per_page’ to 10. The query is returning only activity from the users i specified (so, that’s good), but the pagination is all messed up (not so good).

    I am not using the ‘load’ more button, just the default pagination. bp_activity_pagination_count() is showing the correct per page count, but the actual number of items being displayed varies wildly, from 4 to 10.

    Has anyone else encountered this?

    @xrun

    Member

    @boonebgorges the load more link has shown up at the bottom in the activity feed, the list currently has 13 entries. I’d like to cap it at somewhere between 5 and 10, and then extend the list to another 10 each time the load more-link is hit.
    I have removed the custom php-file temporarily, but while testing this I found that when I clicked the link it wouldn’t do anything, was just sitting there and accepting clicks without loading more.

    @boonebgorges

    Keymaster

    @xrun – Did you check to see whether Load More is working correctly without this custom code? It’s hard to troubleshoot when I don’t know if your problem is related to the additional code.

    @xrun

    Member

    @boonebgorges the Load More-link doesn’t show up at all without the code. I currently have 13 entrys total, but no Load More-link.

    Edit: @boonebgorges
    The Load More-link has finally shown up as the list of activities has gotten longer, but still nothing happens when I click it, except adding #more to the url in the address field in the browser.
    I have realized something that may be significant though. The activities are listed on a subdomain blog, not the main blog, so there might be something with the url when it tries to load more activities.
    This may also be related to the issue when clicking to reply to an activity, as it seems to try to load the form using the subdomain url. When clicking reply while viewing a single activity did and still works like it should, having always been viewed on the main domain, not the subdomain.

    @muchad

    Participant

    put this in your functions.php in your theme

    function my_custom_query_filter( $query_string ) {
    $query_string .= ‘&per_page=10’;
    return $query_string;
    }
    add_filter( ‘bp_dtheme_ajax_querystring’, ‘my_custom_query_filter’ );

    you just change per_page option as you need…
    it’s run for me, you can see here http://blog.uin-malang.ac.id

Viewing 18 replies - 1 through 18 (of 18 total)
  • The topic ‘How to add (\'per_page=35\') without messing up \"Load More\" link’ is closed to new replies.
Skip to toolbar