/** *Count posts of given type, so each user can create post only once */ function u_post_count() { $user_post_count = count( get_posts( array( 'post_type' => 'your_post_type', 'author' => get_current_user_id(), ) ) ); return $user_post_count; }
It will count all Posts of the current logged in user.
Make sure to define the Post type in 'post_type'
It returns a numeric count.
Let us know if this snippet is not working for you:
This snippet doesn’t work