I'm trying to use the code below to obtain the number of custom posts the author of a post has published.
function count_user_posts_by_type( $userid, $post_type = 'artistblog' ) {
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 );
For example I'm outputting a loop of custom post types. Next to each post title I'm displaying the author of the post using a similar get_related_author function. I also want to display the number of posts this author has published. I assume I just need to replace $userid with the_author_meta() somehow but haven't managed to get it working.
Am I even approaching this in the right way?
Thanks D