Skip to:
Content
Pages
Categories
Search
Top
Bottom

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


  • Liesl Fawcett
    Participant

    @liesl1698

    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)

  • danbpfr
    Participant

    @chouf1

    hi,

    did you tried ‘max=35’ ?


    Liesl Fawcett
    Participant

    @liesl1698

    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?


    Liesl Fawcett
    Participant

    @liesl1698

    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.


    danbpfr
    Participant

    @chouf1

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


    Liesl Fawcett
    Participant

    @liesl1698

    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?


    Boone Gorges
    Keymaster

    @boonebgorges

    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


    Liesl Fawcett
    Participant

    @liesl1698

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


    Boone Gorges
    Keymaster

    @boonebgorges

    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.


    Liesl Fawcett
    Participant

    @liesl1698

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


    Boone Gorges
    Keymaster

    @boonebgorges

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


    Liesl Fawcett
    Participant

    @liesl1698

    That worked. Thank you SO much!!!

    @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’ );


    Boone Gorges
    Keymaster

    @boonebgorges

    @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.

    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?

    @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.


    Boone Gorges
    Keymaster

    @boonebgorges

    @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.

    @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

    @muchad

    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