Created
March 23, 2010 11:43
-
-
Save thom4parisot/341080 to your computer and use it in GitHub Desktop.
WordPress − returns the number of posts from a category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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