Wordpress - Count How Many Posts In Category


Answer :

If I remember right count of posts in category is stored persistently in category object. So use get_category() or variation of it and fetch the number out of object.



Example code (not tested):



$category = get_category($id);
$count = $category->category_count;

if( $count > $something ) {

// stuff
}


Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable