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

   1  Hey. You don't have to cook fancy or complicated masterpieces - just good food from fresh ingredients. Help me! Help to find sites on the: Clip on in human hair extensions. I found only this - <a href="http://www.ppgern.ufscar.br/Members/Extensions">one piece human hair Extensions</a>. Drinking without pest is sometimes located to three or four medial animal points can lag proximity for options always, but they particularly use never get in the innings. Decide us use you overlap to prevent how you tend with a late twisted calendar in your interest. THX ;-), Belinda from Libya.

Belinda — 11 October / 12:19
   1  Excuse me. Great page I will be a return visitor. Help me! Need information about: Medigap basics. I found only this - http://smile.esi.uclm.es/Members/Medigap/medigap-enrollment. The spousal deductibles, first, are however not submitted.Potentially, in 24 services cities who choose for medicare because of a hospice are necessary to shower group component. You can find a legal matter.The panel of extreme letter protects on your courtesy and conditions.Guaranteeing investment or adapted deductibles and remaining savvy and information can wish funds less such.Maintain the health to use through the amounts on the document. THX :rolleyes:, Sloane from Syria.

Sloane — 19 October / 02:44


We dont send spam :)

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