Pergunta

I am having trouble adding custom column to Woocommerce Subscription.

My codes are as below:

add_filter( 'manage_shop_subscription_posts_columns', function ($columns) {
    $columns['my_field'] = __('My Field');

    return $columns;
}, 10);

What could be wrong with my code? I fail to understand why it is not working.

Foi útil?

Solução

Alright, so since WC Subscriptions is creating it's own array for columns. Any filter priority lesser than their function will simply make your code non-functional. So what I did is I changed priority from 10 to 1000 so that my codes fire after their code.

add_filter( 'manage_shop_subscription_posts_columns', function ($columns) {
    $columns['my_field'] = __('My Field');

    return $columns;
}, 1000);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a wordpress.stackexchange
scroll top