Support » Fixing WordPress » the_author_posts(); not counting custom post types

  • Hi there,

    I’ve noted that the_author_posts(); template tag didn’t count the custom post types. Just “regular posts” are being counted!

    Is there a way to fix this and count everything written by the authors on my blog?


Viewing 2 replies - 1 through 2 (of 2 total)
  • <?php
    $post_author = 1; //author id
    $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = $post_author AND post_type IN ('post','page','book') and post_status = 'publish'" );
    echo 'count of post types post,page,book for user id 1: '.$count

    MichaelH thanks for your help.

    Can you just tell me how to use that code without have to define the author ID? I mean… it’s a multiauthor blog, so it should retrieve the post count of the specific author of the post, which obviously is not always the same one.

    Again, thanks for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘the_author_posts(); not counting custom post types’ is closed to new replies.