Returns the post count for the user whose ID is passed to it. You can put this snippet wherever you want in theme and will work.

<?php global $user_ID; if ( $user_ID ) : ?>
<?php global $current_user; get_currentuserinfo();  ?>

<?php $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_author = '$current_user->ID;'");
if (0 < $numposts) $numposts = number_format($numposts);
echo $numposts; ?>
 

Leave a Comment