WordPress.org

Ready to get started?Download WordPress

Forums

Liveblog
[resolved] How to query number of liveblog entries for a given post? (5 posts)

  1. eschickel
    Member
    Posted 1 year ago #

    In the loop on my home page I'd like to display the number of liveblog entries for each post. How can I do this?

    http://wordpress.org/extend/plugins/liveblog/

  2. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    Do you have normal comments on liveblog posts too, or are those disabled?

  3. eschickel
    Member
    Posted 1 year ago #

    At the moment they are disabled, but eventually I will be using normal comments and would like to distinguish between the two.

  4. Nikolay Bachiyski
    Key Master
    Plugin Author

    Posted 1 year ago #

    @eschickel, currently there isn't specific API for getting the count, but you can use the following code:

    function get_liveblog_entries_count_for_post_id( $post_id ) {
        $query = new WPCOM_Liveblog_Entry_Query( $post_id, WPCOM_Liveblog::key );
        return count( $query->get_all() );
    }

    If you're using an object cache it would be pretty fast. It's calling get_comments() once under the hood, so it shouldn't be too slow in any case.

  5. eschickel
    Member
    Posted 1 year ago #

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags