You’re using wp_count_posts(
for counting posts, so it will return the number of posts.
If you want to get the number of posts for given user, you should use count_user_posts
instead.
So change this line:
$count_post = wp_count_posts($post_type_name)->publish;
to:
$count_post = count_user_posts( get_current_user_id(), $post_type_name, true );
Related Posts:
- Custom post type for ‘staff’ versus using wordpress user profiles?
- Showing User’s Post Counts by Custom Post Type in the Admin’s User List?
- Prevent trash/delete action on specific post types
- Custom post type support for get_users(‘orderby=post_count’);
- Front end registration/login & publish/update 1 custom post
- User roles – enable custom posts disable posts
- Allow User to Edit Page Based on their Email
- How to restrict specific post types from being read or added by specific user roles (eg. author)?
- How can I get the last posts by user role?
- Assigning a role to a specific custom post type (and ignoring other post types)
- WordPress allow access only one custom post type “xyz” to custom user role but need to hide all admin panels
- How to show custom post type count in the users admin page
- Community and User Generated Content Website: Have been thinking about Drupal but leaning on WordPress heavily
- Delete Current Author Frontend user while delete custom post type
- WP-Admin edit.php & post.php slowdown after import of 10k users
- Link users to a custom post type
- Ajax Check Post Status
- Want to Add Custom Fields for Uploading video to WordPress Users from front end
- how to delete all users and posts based on ‘user_meta’?
- Roles for Custom Post Types
- Is using taxonomies the way to go here or would custom post types be better?
- Hiding posts by other users and non-logged in
- Users create/join groups
- Disable user from updating certain posts
- Query posts based on the meta key values of logged-in users?
- How to restrict author to only access one custom post type ?
- Create custom post with custom user rules
- Associate multiple users to custom post type
- How to assign permissions for a CPT to a user
- How can i display movies in profile page, added by an user?
- Custom User role not working with custom post type
- get comments by current user inside page template
- how to associate several authors to a custom post type
- Assign post type to many users
- Check if user has comment on current post
- Query within a foreach within a query (queryception)
- Showing User’s Post Counts by Custom Post Type in the Author.php?
- Add a custom post when inserting a new user in WordPress?
- Preventing role reading others posts
- Order users by number of posts (includes custom post type)
- Plugin needed to allow subscribers to post articles on the front end without admin approval [closed]
- Display custom post front end filter by ACF equals current user
- users post count
- Clone wp-admin/users.php (Users Admin Page)
- Link custom post type to users membership
- Show all post type posts in manage users posts column
- Get all of a user’s posts (custom post type) then get cumulative value of a specific meta_key value from those posts
- Assign a Post to a User
- Add WordPress users to a custom post type
- Custom Post Type Query by user id
- Autofill advanced custom field with user data
- connect users to Custom post types
- Reference field of users in custom post type
- Custom Post Hierarchy and users
- UPDATED: Save a custom_field value when automatically creating a post using wp_insert_post
- Creating multiple profiles under one user to assign to particular posts
- Allow viewing the edit screen for a post type, but not make/save/publish/update changes
- Control what custom posts a user can see
- Associate custom categories to different user IDs
- Display and Allow users to edit their own profiles
- Check in function on custom page
- WordPress and Unity high scores table
- how to show Author post type count
- Limit CPT to only have a single view page sometimes
- Filtering a WP_Query meta_query by numeric values isn’t working
- Make future posts visible to the public—not just within WP_Query
- How to add button to post page WordPress 5.x
- Filtering custom posts with Ajax
- Order posts by (hierarchical custom) taxonomy terms and term children
- Filter get_categories() for taxonomy term in WordPress
- Hierarchical or Non-hierarchical Custom Post Type in Real World Example
- How can I show some description in the “All Posts” view of a custom post type in Dashboard?
- Add CPT as subpage under custom page
- Conditionally custom post type url rewrite
- Root slug of taxonomy returning 404
- WordPress Custom Post Type Repeated 404 Errors
- Possibilities for the edit.php admin panel? [closed]
- Sort entries by date mixing two post types
- unable to show custom post type featured image
- How can i create an custom post template for an specific post category? [closed]
- Search one custom post type ONLY, disable “all posts”
- Enable Custom Fields For Custom Post Type When CPT Created Using Plugin
- Custom post type, global categories — what’s the template name?
- Excerpt function for any content
- Cannot get custom post
- How to handle this specific case of custom post type?
- Custom Endpoint For Custom Post Type from Child Theme
- How to add href=”” custom post type?
- Add filter to Admin list for all custom post types by their custom taxonomies
- Single.php for Custom Post Type > Taxonomy > Term
- prevent sub categories to show up
- Cannot include custom post item within a menu
- automatic creation of custom post type articles
- Redirection loop error after login from a custom post type post
- install.php Custom Taxonomy Term not being added to custom post
- How to retrieve taxonomy terms of the current custom post?
- Display custom posts in checkbox list
- Change display wp post type to wp custom post type
- Page Attributes Panel (Parent option) is not showing on a custom post type
- WordPress custom field sorting, weird behavior: the latest post is at the end