tags:

views:

107

answers:

1

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
A: 

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/

Zyphrax
Thanks Zyphrax!
Scott B