How to paginate with the live-blogging plug-in:
This will give you 10 posts before comments with a button that says “Load more posts.” When clicked it loads 10 more posts above the button.
live-blogging.php
In function live_blogging_shortcode
right before $post = $parent_post;
add this:
$s .= '<div id="more-entries"></div><!-- /#more-entries -->';
$s .= '<button id="load-more-entries">Load more posts</button>';
Also, change the posts_per_page in WP_Query
to 10 or whatever you want to use, just make sure you keep it consistent in the next function below
Add this to the bottom of live-blogging.php
add_action('wp_ajax_load_more_entries', 'wp_load_more');
add_action('wp_ajax_nopriv_load_more_entries', 'wp_load_more');
function wp_load_more(){
$paged = $_GET['page_no'];
$id = $_GET['id'];
$posts_per_page = get_option('posts_per_page');
$q = query_posts(array(
'paged' => $paged
, 'post_type' => 'liveblog_entry'
, 'post_status' => 'publish'
, 'liveblog' => $id
, 'posts_per_page' => 10
));
while ( have_posts() ) : the_post();
echo '<div id="liveblog-entry-' . $q->post->ID . '">' . live_blogging_get_entry($q->post) . '</div>';
endwhile;
exit;
}
live-blogging.js
In function live_blogging_poll
add this:
jQuery(document).ready(function($) {
var count = 2;
$('#load-more-entries').click(function(){
loadEntries(count);
count++;
});
function loadEntries(pageNumber){
$('a#inifiniteLoader').show('fast');
$.ajax({
url: live_blogging.ajaxurl
, cache: false
, type: 'get'
, data: {
action: 'load_more_entries'
, page_no: pageNumber
, id: id
}
, success: function(html){
$("#more-entries").append(html);
}
});
return false;
}
});