I'm trying to echo the value of the variable in the code below. I'm getting an error 开发者_开发百科(see below)...
Here's the code...
$mypagecount = wp_count_posts('page');
echo $mypagecount;
Here's the error:
Catchable fatal error: Object of class stdClass could not be converted to string
The wp_count_posts function returns an object.
You can ask the object to return the number of publish items.
<?php
$count_pages = wp_count_posts('page');
$pages = $count_pages->publish;
echo $pages;
?>
For more information:
http://wpengineer.com/show-amount-of-posts-pages-categories-tags-comments-for-wordpress-themes/
精彩评论