Get how many posts are returned by a custom loop

Simply paste the following code snippet anywhere on your theme. It will display how many posts are returned by the custom query.

$feat_loop = new WP_Query( 'showposts=12&category_name=featured' );
echo "Query returned ".$feat_loop->post_count." posts.";

Thanks to WP Lover for the cool tip!

Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!

Get how many posts are returned by a custom loop

Leave a Reply

Your email address will not be published. Required fields are marked *