Support » Themes and Templates » TT: wp_count_posts, how to get it working?

  • Hello.

    I discovered a new template tag from the Codex, wp_count_posts. I tried to apply it like it said on that page, but I keep getting a PHP error:

    Catchable fatal error: Object of class stdClass could not be converted to string in ...\wordpress\wp-content\themes\rdegree4\archives.php on line 37

    What I’m trying to do is to simply give a count of how many published posts I’ve got on WordPress.

    <?php $num_posts = wp_count_posts(); ?>
    	<h3>All posts ordered by date (totaling at <?php echo $num_posts ?> posts)</h3>

    What’s wrong with that? Do I need to include something else too? Something server-side? Or is the syntax horribly wrong (yeah, PHP isn’t my best craft)? What?

    All help appreciated. Thanks. 🙂

    And I did try and search for an answer but didn’t find anything… :S

  • The topic ‘TT: wp_count_posts, how to get it working?’ is closed to new replies.