Get the Number of All Posts in WordPress
By: Zhiqiang Ma
On: Jan 29, 2010
Views: 18 No Comment
Print
Email
Tags: php, tutorials, Web, wordpress
Tags: php, tutorials, Web, wordpress
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:
- Put the categories, archives and all posts into pages
- Friendly WordPress navigation using page numbers instead of next and previous links
- RGBlite WordPress Theme
- Change WordPress’s excerpt length
- How to redirect WordPress feed to feedburner using .htaccess
- Use Excerpt in Index, Category, Tag and Arhieve Pages for WordPress
















Leave your response!