Home » Web

Get the number of all posts in WordPress

By: Zhiqiang Ma On: Jan 29, 2010 Views: 16 No Comment Print Email
Tags: , , ,

Use the wp_count_posts() function to get the posts count.
The code:

<?php
  $count_posts = wp_count_posts();
  $count_pages = wp_count_posts('page');
  echo "<li><a href=" . get_option('home') . ">";
  echo $count_posts->publish . " Posts, " . $count_pages->publish . " Pages";
  echo "</a></li>"
?>

Read more:

Digg del.icio.us Stumble Techorati Facebook Newsvine Reddit Twitter
Mixx LinkedIn Google Bookmark Yahoo Bookmark MySpace LiveJournal Blogger RSS feed
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.