2

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).

Any suggestions?

3

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);
?>
  • Sorry, where should I place that code? – janoChen Jun 28 '11 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.