count_user_posts() doesn’t support the second parameter ($post_type in your code), according to the docs.
There is a function at the bottom of the docs page that allows you do filter by post_type, you could drop in functions.php and use.
Related Posts:
- Getting all user metadata from user
- How to add custom query filters in WP_User_Query
- WP User Query get all authors with last name starting with specific letter
- Reduce number of SQL queries inside WP_Query loop to fetch author data
- Random users always showing same 8 users
- How to query 5 users in random who have published more than 10 posts
- Searching user meta using WP_User_Query
- Filter user list that meta_value is empty
- Query wp_usermeta alongside wp_users
- SQL User Query by Multiple Roles using PHP
- WP_User_Query unable to retreive all user at once
- Sort users by “birthday” using WP_User_Query
- Hide Administrators From User List except current user (administrator)
- WordPress search posts by author name with autocomplete
- pagination with numbers for WP_User_Query
- How to display user order by role
- Import wp users via one click demo option
- Dynamic User Id
- Get users that likes the post
- Prevent author bio page from showing in search results
- Get multiple users with meta value in one query and populate WP_User class
- Display if author page is author page of current user
- array of meta values using WP_User_Query
- Get user first name from custom endpoint
- How to properly use AND / OR in custom search
- WP_User_Query and user posts
- construct complex queries with WP User Query
- Storing an array of objects related to each user
- Create one-use post dynamically, add to main query, do not insert post (user profile view)
- WP_User_Query orderby meta_val_num
- Query to get last posts from authors of blog
- Replace wp_query with wp_user_query
- Query pages created by deleted users
- Query posts by post type, author and post meta
- SQL to join u3g_users & u3g_meta_value with repeating data
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- WP_User_Query Orderby Not Working
- Set “editor” role to existing user
- How to query users by post count no less than 10
- Merge wp-query and get_users
- Get all wp_users sort by metakey
- Logging search queries for logged-in users
- WP_User_Query not searching numbers?
- List users by Year of Birth using a foreach loop to dynamically populate years and data
- Show subscriber id in loop
- Search Functionality broken by the wp 4.2 update
- Get users query makes the site loading time too big?
- Get all user with both meta_value
- WordPress WP_User_Query ignores the `meta_query` when called from an Ajax function
- Orderby meta _value that is saved as an array
- Group users by meta field, with name of meta field as group title
- Complicated `orderby` based on text in custom field
- Using a Query Loop Block with Variables (Custom Meta)
- Query posts only with featured image
- why ignore_sticky_posts in sticky post query
- get_query_var function not working at all
- get_query_var( ‘paged’ ) not working outside of homepage
- Order by Category and Post in WP custom Query
- get custom post type by tag
- Does tax_query really beats meta_query in all situations?
- WP_Query by post ID doesn’t work if post is in custom post_status
- Execute a large WP_Query with many “AND” Meta_Queries?
- Using WP_Query To Get Posts Randomly From today
- How to know which one is the main query?
- WP_Query can’t exclude more than 1 author?
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- How to order posts by custom WP role?
- Generate a tabbed submenu — from taxonomy term or submenu item — with sample content
- posts2posts query using connected_items array issue [closed]
- WP Query and order by particular specified IDs
- Get the post permalink within the loop but without additional DB query
- How to use search_columns in WP_User_Query?
- Display revision if post status is pending
- Meta query field order together with post_date order causes posts without the meta field to be unordered
- How To Remove/hide some specific categories from two different categories widget from sidebar
- WP Query search for attachments and their exact title
- How to add another parameters to WP_Query?
- Display link to taxonomy archive only if it has posts with certain custom field values
- Undefined property: WP_Query::$post
- Excluding Sticky Posts from The Loop and from WP_Query() in WordPress?
- How to display posts month by month?
- WP User Query fails when searching meta queries and search columns
- Display posts with date wordpress default
- Query different number of posts with different formats in one go
- Extending woocommerce admin product search
- Pagination is broken and I need help fixing it
- Query total number of posts
- Category attribute not working in custom shortcode
- How to display a posts 1 year ago with custom WP_Query loop?
- need to exclude APP_TAX_STORE => $term->slug
- Check on which page specific result exist
- WC displaying products from category
- Show all post for a given category
- Loop returning only 1 result
- Fetch posts that match term slug first two letters (wp query)
- how to know when the user is in specific part of the website and when he leaves that part and display the data in the admin dashboard
- How can I use $wp_query->tax_query as tax_query parameter for a new WP_Query instatiation?
- How does one perform a sub query with different post types
- Query with search and subscribers only output
- Stuck in the query loop