Skip to content

Instantly share code, notes, and snippets.

@thom4parisot
Created March 23, 2010 11:43
Show Gist options
  • Save thom4parisot/341080 to your computer and use it in GitHub Desktop.
Save thom4parisot/341080 to your computer and use it in GitHub Desktop.
WordPress − returns the number of posts from a category
<?php
/**
* Returns the number of posts from a category
*
*
* @version 1.0
* @since 2010-03-23
* @author Oncle Tom <http://case.oncle-tom.net>
* @param integer $category_id
* @return integer|NULL Number of posts, NULL if category does not exists
*/
function get_category_count($category_id)
{
$category_data = get_category($category_id, ARRAY_A);
return !empty($category_data) && isset($category_data['category_count']) ? (int)$category_data['category_count'] : NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment