I created a new column in the Users Admin Tab where it says how many Listings an user has.
//// ADD THE NEW COLUMN
add_filter( 'manage_users_columns', 'add_listing_count_column' );
function add_listing_count_column( $columns ) {
$columns['Listings'] = 'Listings'; //
return $columns;}
// FILL THE NEW COLUMN
add_filter( 'manage_users_custom_column', 'add_listing_count_column_row', 10, 3 );
function add_listing_count_column_row( $row_output, $column_id_attr, $user_id ) {
if ( $column_id_attr == 'Listings') {
return count_user_posts( $user_id, 'job_listing' );
}
return $row_output;}
now I'm trying to sort the numbers. But it keeps sorting by username...
// MAKE THE NEW COLUMN SORTABLE
add_filter( 'manage_users_sortable_columns', 'add_listing_count_column_sortable');
function add_listing_count_column_sortable( $columns ) {
return wp_parse_args( array( 'Listings' => 'Listings' ), $columns );}