如何在管理面板中为 woocommerce 订阅表添加自定义过滤器?因为当我在下面使用此代码时,表格会返回所有帖子
add_filter( 'request', 'subs_filter_retry_count', 999 );
function subs_filter_retry_count( $vars ){
global $typenow;
if ( 'shop_subscription' === $typenow ) {
// Filter the orders by the posted customer.
if ( isset( $_GET['_retry_count_filter'] ) && $_GET['_retry_count_filter'] > 0 ) {
$vars['meta_query'][] = array(
'key' => '_customer_user',
'value' => (int) $_GET['_retry_count_filter'],
'compare' => '=',
);
}
}
return $vars;
}
add_action('restrict_manage_posts', 'test_test_function');
function test_test_function(){
global $typenow;
if ( 'shop_subscription' !== $typenow ) {
return;
}
woocommerce_wp_text_input( array(
'id' => '_retry_count_filter',
'placeholder' => 'Retry count filter',
'label' => 'Retry count filter',
) );
}