![](/img/trans.png)
[英]How to create a filter dropdown on WooCommerce admin orders list?
[英]Remove a dropdown select field filter in Woocommerce admin orders list
您要删除的选择器是自定义的,并且肯定是由第三方插件添加的。
您可以尝试使用隐藏在admin_head
操作挂钩中的自定义函数来隐藏下拉选择器字段。 您需要用要隐藏的选择器的ID或类替换CSS ID #my_selector_id
(使用浏览器代码检查器找到正确的选择器)
add_action( 'admin_head', 'adding_custom_css_in_admin_head', 999 );
function adding_custom_css_in_admin_head() {
?>
<style type="text/css">
body.post-type-shop_order select#my_selector_id {
display: none !important;
}
</style>
<?php
}
代码在您的活动子主题(或主题)的function.php文件中,或者在任何插件文件中。
此代码已经过测试,应与您的下拉选择器字段一起使用。
我通过使用CSS删除了我在function.php中添加了此功能
add_action('admin_head', 'hidey_admin_head');
function hidey_admin_head() {
echo '<style type="text/css">';
echo 'select[name=_customer_shipping_country] {display: none;}';
echo '</style>';
}
所选答案不是最佳解决方案,因为仍会创建过滤器,它们只是被隐藏。 相反,您应该挂钩正确的过滤器并阻止WooCommerce插件创建选择框:
add_filter( 'woocommerce_products_admin_list_table_filters', 'my_woocommerce_products_admin_list_table_filters' );
function my_woocommerce_products_admin_list_table_filters( $filters ) {
// to remove the category filter
if( isset( $filters['product_category'] ) ) {
unset( $filters['product_category'] );
}
// to remove the product type filter
if( isset( $filters['product_type'] ) ) {
unset( $filters['product_type'] );
}
// to remove the stock filter
if( isset( $filters['stock_status'] ) ) {
unset( $filters['stock_status'] );
}
return $filters;
}
您可以尝试使用隐藏在admin_head操作挂钩中的自定义函数来隐藏下拉选择器字段。 您将需要用要隐藏的选择器的ID或类替换CSS ID #my_selector_id
(使用浏览器代码检查器找到正确的选择器),您可以转到开发人员的,查看属性是否按预期工作浏览器的工具,然后选择每个元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.