Counting the posts of a custom WordPress loop (WP_Query)?

Correct way of getting the total number of posts is:

<?php $count = $custom_posts->found_posts; ?>

http://codex.wordpress.org/Class_Reference/WP_Query#Properties

Edit: acknowledging @Kresimir Pendic’s answer as probably correct. post_count is the count of posts for that particular page, while found_posts is the count for all available posts that meets the requirements of the query without pagination. Thank you for the correction.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)