Skip to main content

Here is a quick solution to get the post count any kind of filtering you want

function custom_get_user_posts_count($user_id, $args ); { 
    $args['author'] = $user;$user_id;
    $args['fields'] = 'ids';
    $ps = get_posts($args);
    return count($ps);
}

Since this function uses get_posts you can filter and use anything that you can with WP_Query

So in your case you can use it like this:

$count = custom_get_user_posts_count($user_id, array(
    'post_type' =>'post',
    'post_status'=> 'draft'
));

Here is a quick solution to get the post count any kind of filtering you want

function custom_get_user_posts_count($user_id,$args );  
    $args['author'] = $user;
    $args['fields'] = 'ids';
    $ps = get_posts($args);
    return count($ps);
}

Since this function uses get_posts you can filter and use anything that you can with WP_Query

So in your case you can use it like this:

$count = custom_get_user_posts_count($user_id, array(
    'post_type' =>'post',
    'post_status'=> 'draft'
));

Here is a quick solution to get the post count any kind of filtering you want

function custom_get_user_posts_count($user_id, $args ){ 
    $args['author'] = $user_id;
    $args['fields'] = 'ids';
    $ps = get_posts($args);
    return count($ps);
}

Since this function uses get_posts you can filter and use anything that you can with WP_Query

So in your case you can use it like this:

$count = custom_get_user_posts_count($user_id, array(
    'post_type' =>'post',
    'post_status'=> 'draft'
));

hereHere is a quick solution to get the post count any kind of filtering you want

function custom_get_user_posts_count($user_id,$args );  
    $args['author'] = $user;
    $args['fields'] = 'ids';
    $ps = get_posts($args);
    return count($ps);
}

sinceSince this function uses get_postsget_posts you can filter and use anything that you can with WP_QueryWP_Query

soSo in your case you can use it like this:

$count = custom_get_user_posts_count($user_id, array(
    'post_type' =>'post',
    'post_status'=> 'draft' 
));

here is a quick solution to get the post count any kind of filtering you want

function custom_get_user_posts_count($user_id,$args );  
    $args['author'] = $user;
    $args['fields'] = 'ids';
    $ps = get_posts($args);
    return count($ps);
}

since this function uses get_posts you can filter and use anything that you can with WP_Query

so in your case you can use it like this:

$count = custom_get_user_posts_count($user_id,array('post_type' =>'post','post_status'=> 'draft'));

Here is a quick solution to get the post count any kind of filtering you want

function custom_get_user_posts_count($user_id,$args );  
    $args['author'] = $user;
    $args['fields'] = 'ids';
    $ps = get_posts($args);
    return count($ps);
}

Since this function uses get_posts you can filter and use anything that you can with WP_Query

So in your case you can use it like this:

$count = custom_get_user_posts_count($user_id, array(
    'post_type' =>'post',
    'post_status'=> 'draft' 
));
Source Link
Bainternet
  • 67.7k
  • 8
  • 131
  • 188

here is a quick solution to get the post count any kind of filtering you want

function custom_get_user_posts_count($user_id,$args );  
    $args['author'] = $user;
    $args['fields'] = 'ids';
    $ps = get_posts($args);
    return count($ps);
}

since this function uses get_posts you can filter and use anything that you can with WP_Query

so in your case you can use it like this:

$count = custom_get_user_posts_count($user_id,array('post_type' =>'post','post_status'=> 'draft'));