Displaying the number of posts in a custom loop (without including the number of posts of a loop below)?

I have this custom loop:

<?php // Display the top ones
    $args = array(
        'post_type' => 'reply',
        'post_parent' => $post->ID,
        'r_sortby' => 'highest_rated',
        'r_orderby' => 'desc',
        'order' => 'DESC'
    );
?>


<?php query_posts( $args ); ?>

<div class="entry-list-top">

<?php while ( have_posts() ) : the_post(); ?>

    <h2 class="dark-title"><?php _e( 'Top Replies' ); ?></h2>

    <div class="topic-entry">
        <div class="topic-author">
            <?php bbp_reply_author_link( array( 'type' => 'avatar' ) ); ?>
        </div>

        <div class="topic-content">
            <span class="topic-author-link"><?php bbp_reply_author_link( array( 'type' => 'name' ) ); ?></span>
            <?php bbp_reply_admin_links(); ?>
            <span class="topic-post-date"><?php printf( __( '<span>%1$s</span> <span>at %2$s</span>', 'bbpress' ), get_the_date(), esc_attr( get_the_time() ) ); ?></span>
            <?php bbp_reply_content(); ?>

        <div class="tt-like-button">
            <?php if(function_exists('the_ratings')) { the_ratings(); } ?>
        </div>

        </div>

    </div>

    <?php $most_voted[] = get_the_ID(); // get the id of the most voted post ?>

<?php endwhile; ?>

I would like to retrieve the number of posts (only in this loop).
(The is another loop below).

Read More

Any suggestions?

Related posts

Leave a Reply

1 comment

  1. Just count the number of returned posts of the first loop:

    Replace:

    <?php query_posts( $args ); ?>
    

    With:

    <?php
    $posts = query_posts( $args );
    $count = count($posts);
    ?>