How can I get count from the query post in WordPress?

To get the WordPress row counts in the query post use this code:

$obj_name = new WP_Query($args);
while ($obj_name->have_posts()) : $obj_name->the_post(); 
    $num = $obj_name->post_count; 
endwhile;

This code helps you count

$num = $obj_name->post_count; 

Now print $num

Reference: wp_query

Leave a Comment