2

I am trying to remove some default columns (amount & products) from the WooCommerce admin coupon list.

For that I make use of the following code:

add_filter( 'manage_posts_columns', 'custom_post_columns', 10, 2 );
function custom_post_columns( $columns, $post_type ) {
  
    switch ( $post_type ) {    
    
    case 'shop_coupon':
        unset(
            $columns['amount'],
            $columns['products']
        );
        break;
    }

    return $columns;
}

But it doesn't work and I'm not getting any errors. I think the code I'm using is just not being applied correctly.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Joy Zalte
  • 91
  • 10

1 Answers1

4

You can use the manage_edit-{post type or taxonomy}_columns filter hook

So you get:

function filter_manage_edit_shop_coupon_columns( $columns ) {
    // Remove
    unset( $columns['products'] );
    unset( $columns['amount'] );    

    return $columns;
}
add_filter( 'manage_edit-shop_coupon_columns', 'filter_manage_edit_shop_coupon_columns', 10, 1 );
7uc1f3r
  • 28,449
  • 17
  • 32
  • 50