i have a wordpress site that has around 20000 post
it gets slow at generating pagination. i have traced the problem.
$my_query = new WP_Query($query_string ."&posts_per_page=-1");
$total_posts = $my_query->post_count;
is there any other faster way to get total post on a selected category.
I have one solution for you.
This code will show and unordered list with the name of the category and the count of posts containded in it.
Retrieves the 100 first categories
and for each of them shows
cat_name
andcategory_count
Well the result I presume you really need can now be handled in a var by
$cat->category_count
, i.e:I hope that could help you.
It seems there isn’t one. The default WordPress count function does not support category posts count:
http://codex.wordpress.org/Function_Reference/wp_count_posts
you can use
get_category
: