Posted By

mihael on 06/29/10


Tagged

post wordpress count


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

maxvee8


WordPress: Get the posts count for given category


 / Published in: PHP
 

Returns the number of published posts in the given category.

  1. // @ WordPress
  2. // Returns the total number of posts in given category
  3. // --------------------------------------------------------
  4. function count_total_posts($cat) {
  5.  
  6. foreach((get_the_category()) as $category) {
  7.  
  8. if( $category->cat_ID == $cat ) return $category->category_count;
  9.  
  10. }
  11.  
  12. }
  13. //----------------------------------------------------------

Report this snippet  

You need to login to post a comment.