WordPress.org

Ready to get started?Download WordPress

Forums

Live Blogging
Live Blogging: Limit length of liveblog / paginate liveblog (8 posts)

  1. Dan
    Member
    Posted 2 years ago #

    The Live Blogging plugin is great. Anyone know how to limit the length of the liveblog, so that comments don't appear several miles down the page?
    Ideally, I reckon you'd want about 25/30 or so entries before a 'read older entries' tag that linked to another page.
    Comments are an essential part of a liveblog and visitors often spend as much time interacting with the comments as they do with the liveblog. I can use a comments widget to display the latest comments in the sidebar, but that's not quite enough.
    Any ideas ...
    Thanks

    http://wordpress.org/extend/plugins/live-blogging/

  2. Yuri Victor
    Member
    Posted 2 years ago #

    This would be a nice option to have.

  3. Yuri Victor
    Member
    Posted 1 year ago #

    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;
        }
    });
  4. itcafeonline
    Member
    Posted 1 year ago #

    Can I please reuqest you to package this within the parent plugin and have it uploaded some place please please. have tried the steps above and it does not seem to work. Paginating this plugin is crucial to sucess of my website. Thanks

  5. Yuri Victor
    Member
    Posted 1 year ago #

    @itcafeonline No problem. Give me a week. I'll throw it up on github.

  6. itcafeonline
    Member
    Posted 1 year ago #

    @yurivictor - Thanks so much

  7. chrisnorthwood
    Member
    Plugin Author

    Posted 1 year ago #

    yurivictor, if you're putting it up on Github can you send me a pull request? I'll be able to look into merging it in to the parent then

    https://github.com/cnorthwood/liveblogging

    Thanks

  8. jonnyd86
    Member
    Posted 1 year ago #

    yuri, I followed your instructions and it seems to work but not completely

    first, the liveblog has to be enabled for it to work. is there anyway to change this?

    secondly, when i click the load more pages button, ALL of the posts load above the 20 (which I set my posts per page at) that originally loaded, which remained there, making it very confusing when scrolling.

    I was wondering if these were known issues or if you could help me fix them?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic