Convert a WP Query into a simpler SQL query to fetch only COUNT of posts
You can also try below code to retrieve count of rows. $myquery = $wpdb->get_results( “SELECT * FROM tablename WHERE ID=’some-value'” ); echo $wpdb->num_rows; Let me know if you have any problem. cheers