you are in: codestackercodes [RSS]wordpress functions to count posts

wordpress functions to count posts Delicious Email

for example: save all functions in ‘your_theme/stats.php’

show/hide lines
   1  // comments_count
   2  function comments_count() { 
   3      global $wpdb; 
   4      $count = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"; 
   5      echo $wpdb->get_var($count); 
   6  } 
   7  // < ?php comments_count() ?> comments
   8  
   9  // posts_count
  10  function posts_count() { 
  11      global $wpdb; 
  12      $count = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'"; 
  13      echo $wpdb->get_var($count); 
  14  } 
  15  // <?php posts_count() ?></strong> articles
  16  
  17  // retro_count
  18  function retro_count() { 
  19      global $wpdb; 
  20      $count = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_type = 'pingback'"; 
  21      echo $wpdb->get_var($count); 
  22  } 
  23  // < ?php retro_count() ?> pingbacks
created by leozera — 18 November 2008 — get a short url — tags: php wordpress embed

Comments



We dont send spam :)

If checked, it's highlights your comment
simple_captcha.jpg
Are you a human? Type the code from the image