“Load-more” button in the activity stream page in buddypress is not working for me. If clicked means , it disappearing suddenly but no more posts are loaded.
<?php if ( bp_get_activity_count() == bp_get_activity_per_page() ) : ?>
<li class="load-more clear">
<a href="#more"><?php _e( 'Load More', 'buddypress' ) ?></a> <span class="ajax-loader"></span>
</li>
<?php endif; ?>
I want to load activities like Facebook or by means of load more button.
So I tried the following code snippet got from buddypress forum
// Change:
<li class="load-more">
<a href="#more"><?php _e( 'Load More', 'buddypress' ); ?></a>
</li>
// For this:
<?php if ( ! bp_activity_has_more_items() ) : ?>
<script type="text/javascript">
jq('.pixelMonitor').remove();
jq(document).unbind('scroll');
</script>
<?php endif; ?>
// 2) Add this at the bottom of that file:
<div class="pixelMonitor" style="width: 1px; height: 1px; position: fixed; bottom: 0;">
<div id="loadingActivityMessage" style="background-color: white; border-radius: 7px 7px 7px 7px; bottom: 4px; display: none; float: right; height: 16px; padding: 4px 2px 4px 39px; position: fixed; width: 100px;">Loading...</div>
<script type="text/javascript">
/* Auto load more updates at the end of the page when reaching the bottom of the page */
jq(document).ready( function() {
iterationAllowed = true;
function loadActivityOnScroll(){
jq("#loadingActivityMessage").show();
if ( null == jq.cookie('bp-activity-oldestpage') )
jq.cookie('bp-activity-oldestpage', 1, {path: '/'} );
var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1;
jq.post( ajaxurl, {
action: 'activity_get_older_updates',
'cookie': encodeURIComponent(document.cookie),
'page': oldest_page
},
function(response){
jq("#loadingActivityMessage").hide();
jq.cookie( 'bp-activity-oldestpage', oldest_page, {path: '/'} );
jq("#content ul.activity-list").append(response.contents);
}, 'json' );
return false;
};
jq(document).scroll(function(){
if ( Math.round(jq('.pixelMonitor').last().offset().top) > ( jq(document).height() -500 ) && iterationAllowed === true ) {
loadActivityOnScroll();
iterationAllowed = false;
setTimeout('iterationAllowed = true', 3000);
};
});
}); /* Auto load more activity block ending here */
</script>
Does any one got this and get solved?
Please ,
Thanks in advance.
<li class="load-more">
<a href="#more"><?php _e( 'Load More', 'buddypress' ); ?></a>
</li>
I have added back the following code with all
and now it s working when I’m clicking the Load more button but the “Loadmore…” is not showing!
It needs to be inside a div with id “content” in order to work (check the buddypress global.js file to see why!)