# Custom Post Type Counts in the Users List

> Adds a column per custom post type to the Users screen showing how many published items each user has, next to the built-in Posts count.

- Type: PHP
- Runs: Admin only
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: users, columns, post-types
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/post-type-counts-users-column/

## Code

```php
// Post types to count. Leave empty to use every public custom post type.
$wpide_user_count_types = array();

$wpide_user_count_types_resolved = function () use ( $wpide_user_count_types ) {
    return $wpide_user_count_types ? $wpide_user_count_types : array_values( get_post_types( array( 'public' => true, '_builtin' => false ) ) );
};

add_filter( 'manage_users_columns', function ( $columns ) use ( $wpide_user_count_types_resolved ) {
    foreach ( $wpide_user_count_types_resolved() as $type ) {
        $object = get_post_type_object( $type );
        if ( $object ) {
            $columns[ 'wpide_count_' . $type ] = esc_html( $object->labels->name );
        }
    }

    return $columns;
} );

add_filter( 'manage_users_custom_column', function ( $output, $column, $user_id ) {
    if ( 0 !== strpos( $column, 'wpide_count_' ) ) {
        return $output;
    }

    $type  = substr( $column, strlen( 'wpide_count_' ) );
    $count = (int) count_user_posts( $user_id, $type, true );

    if ( ! $count ) {
        return '0';
    }

    return sprintf( '<a href="%s">%d</a>', esc_url( admin_url( 'edit.php?post_type=' . $type . '&author=' . $user_id ) ), $count );
}, 10, 3 );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Custom Post Type Counts in the Users List" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
