Support » Fixing WordPress » Count Items in Loop

  • I have created a Custom Post Type, and modified the archives loop to output just the link to the Custom Post.

    Is it possible to count the number of items extracted from the database using the loop?

    This is my loop query:
    $loop = new WP_Query( array( 'post_type' => 'cclub', 'orderby' => 'title', 'order' => 'ASC' ) );

    I thought I could count the items using the count() function from PHP using the follow:
    $count = count($loop);

    But alas the answer given was 1.

  • The topic ‘Count Items in Loop’ is closed to new replies.