The solution is simple. Add the word num
when defining the column like this:
// Add users table header columns
add_filter( 'manage_users_columns', 'gtp_users_table_columns' );
function gtp_users_table_columns( $defaults ) {
$defaults['purchased-leads num'] = __( 'Purchased leads', 'gtp_translate' );
return $defaults;
}
// Add users table lead purchase column content
add_action( 'manage_users_custom_column', 'gtp_users_table_content', 10, 3 );
function gtp_users_table_content( $value, $column_name, $user_id ) {
$leads = gtp_get_leads_by_buyer( $user_id );
switch( $column_name ) {
case 'purchased-leads num' :
return $leads->found_posts;
break;
}
}
There are only two changes to your original code:
- changed
$defaults['purchased-leads']
to$defaults['purchased-leads num']
in the first function - changed
case 'purchased-leads'
tocase 'purchased-leads num'
in the second function
WordPress will then assign the num
class to both the header and the column.
There is no need for any additional div or other element. This will work also for any other custom classes that you would like to add.