从 WooCommerce 管理员优惠券列表中删除列

问题描述

我正在尝试从 WooCommerce 管理员优惠券列表中删除一些默认列(金额和产品)。

为此,我使用以下代码:

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

但它不起作用,我没有收到任何错误。我认为我使用的代码没有正确应用。

解决方法

您可以使用 <div class="row"> <div class="col-6 col-md-3">.col-6 .col-md-3</div> <div class="col-6 col-md-3 order-md-3">.col-6 .col-md-3</div> <div class="col-12 col-md-6 order-md-2">.col-12 .col-md-6</div> </div> 过滤器钩子

所以你得到:

manage_edit-{post type or taxonomy}_columns

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...