WordPress.org

Ready to get started?Download WordPress

Forums

TT: wp_count_posts, how to get it working? (1 post)

  1. Rask
    Member
    Posted 6 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic