questions

Remove columns from WooCommerce admin coupon list

Rate this post

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.

 

✔️Solution:

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 );

Leave a Reply

Your email address will not be published.

Back to top button