I'm using the following function to count the number of posts an author has made from a custom post type.
<?php
function count_user_posts_by_type($userid, $post_type) {
global $wpdb;
$where = get_posts_by_author_sql($post_type, TRUE, $userid);
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );
return apply_filters('get_usernumposts', $count, $userid);
}
?>
To echo out the count I use
<?php echo count_user_posts_by_type(wp_get_current_user()->ID, 'custom_post_type_name'); ?>
From my testing it seems to count just the posts that have a post_status of publish. How can I modify the function so it also counts posts that are draft ?
I've tried to modify the query as follows but it seems to have no effect whatsoever:
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where AND post_status IN ('publish','draft')" );