Skip to:
Content
Pages
Categories
Search
Top
Bottom

How can I get a paged activity-stream instead of the "Load more"?

  • @nickrita

    Participant

    I rather would like to have a paged activity-stream instead of the load-more function.

    If possible, it should show the pagination at the beginning and at the end of the posts.

    I know I have to edit the activity-loop.php, but don’t know, how.

    Thanks for any help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • @mariusooms

    Participant

    This is the code for pagination:

    <div class="pagination">
    <div class="pag-count"><?php bp_activity_pagination_count() ?></div>
    <div class="pagination-links"><?php bp_activity_pagination_links() ?></div>
    </div>

    It is already on that page, but it wrapped in <noscript> tags. Just remove those tags and should be good for the top of the page. Just repeat that code somewhere at the bottom, preferably just before the <?php else : ?> statement.

    To remove to “load More” tab remove or uncomment the following code on that same template:

    <?php if ( bp_get_activity_count() == bp_get_activity_per_page() ) : ?>
    <li class="load-more">
    <a href="#more"><?php _e( 'Load More', 'buddypress' ) ?></a>   <span class="ajax-loader"></span>
    </li>
    <?php endif; ?>

    Also look at this codex page, it could be helpful to show you a number of things:

    https://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-activity-stream-loop/

    @nickrita

    Participant

    Marius, I did exactly this, but it didn’t work, until I found another thread. The problem was, that the links were shown, but they didn’t give a result. To solve thist, here’s what Andy said: “You either need to write the AJAX function to handle this (you should be able to copy something from one of the core components) or put a class=”no-ajax” on the surrounding div. “

    So, using your funtion an adding the no-ajax class, my activity-loop.php in my child-theme now looks like this and it works. Thank you very much for your help!

    <?php /* Querystring is set via AJAX in _inc/ajax.php - bp_dtheme_activity_loop() */ ?>

    <?php do_action( 'bp_before_activity_loop' ) ?>

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

    <?php /* Show pagination if JS is not enabled, since the "Load More" link will do nothing */ ?>

    <div class="pagination">

    <div class="no-ajax"><div class="pag-count"><?php bp_activity_pagination_count() ?></div>

    <div class="pagination-links"><?php bp_activity_pagination_links() ?></div>

    </div></div>

    <?php if ( empty( $_POST['page'] ) ) : ?>

    <ul id="activity-stream" class="activity-list item-list">

    <?php endif; ?>

    <?php while ( bp_activities() ) : bp_the_activity(); ?>

    <?php include( locate_template( array( 'activity/entry.php' ), false ) ) ?>

    <?php endwhile; ?>

    <?php if ( bp_get_activity_count() == bp_get_activity_per_page() ) : ?>

    <noscript><li class="load-more">

    <?php _e( 'Load More', 'buddypress' ) ?>   <span class="ajax-loader"></span>

    <?php endif; ?></noscript>

    <?php if ( empty( $_POST['page'] ) ) : ?>

    <?php endif; ?>

    <?php else : ?>

    <div id="message" class="info">

    <p><?php _e( 'Sorry, there was no activity found. Please try a different filter.', 'buddypress' ) ?></p>

    </div>

    <?php endif; ?><div class="pagination">

    <div class="no-ajax"><div class="pag-count"><?php bp_activity_pagination_count() ?></div>

    <div class="pagination-links"><?php bp_activity_pagination_links() ?></div>

    </div></div>

    <?php do_action( 'bp_after_activity_loop' ) ?>

    <form action="" name="activity-loop-form" id="activity-loop-form" method="post">

    <?php wp_nonce_field( 'activity_filter', '_wpnonce_activity_filter' ) ?>

    </form>

    You can see it running on http://netzkritzler.de.

    The last page is not shown, I don’t know why, but that doesn’t really matter.

    @antonrsaopencirclecoza

    Participant

    That method works for pagination of the main activity but it doesn’t work if you filter the activity and then click on any of the next pages. It loads wp-load.php?acpage and it results in a blank page.

    @kevbow

    Participant

    This does not work. When you click to go to the next page it just goes to a blank page. I was able to get rid of the load more. Is there a way or code that I can use to get it to work when you click on the page 2, page 3, etc?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How can I get a paged activity-stream instead of the "Load more"?’ is closed to new replies.
Skip to toolbar