How to Hide Unused Widgets in WooCommerce Admin Panel
Explanation
If you're looking to tidy up your WooCommerce admin area by hiding widgets you don't use, this code will help you do just that.
Remove Dashboard Widgets:
- This part of the code removes certain widgets from your WordPress admin dashboard. Widgets like WooCommerce Status, Recent Reviews, and Recent Orders will no longer clutter your view.
Unregister Sidebar Widgets:
- The second function targets the widgets that appear in your site's sidebar. It unregisters a variety of WooCommerce widgets such as Recent Products, Featured Products, and Product Categories, among others.
By using this code, you can streamline your WooCommerce interface, making it easier to focus on the tools you actually use. Just add this snippet to your theme's functions.php file, and you'll have a cleaner, more efficient admin panel and sidebar.
Code
<?php
// Function to remove unused WooCommerce widgets from the WordPress admin dashboard
function wp_dudecom_remove_woocommerce_dashboard_widgets() {
// Remove specific WooCommerce dashboard widgets
remove_meta_box('woocommerce_dashboard_status', 'dashboard', 'normal'); // WooCommerce Status
remove_meta_box('woocommerce_dashboard_recent_reviews', 'dashboard', 'normal'); // Recent Reviews
remove_meta_box('woocommerce_dashboard_recent_orders', 'dashboard', 'normal'); // Recent Orders
}
add_action('wp_dashboard_setup', 'wp_dudecom_remove_woocommerce_dashboard_widgets');
// Function to unregister unused WooCommerce widgets from the WordPress widgets panel
function wp_dudecom_unregister_woocommerce_widgets() {
// Unregister specific WooCommerce widgets
unregister_widget('WC_Widget_Recent_Products');
unregister_widget('WC_Widget_Featured_Products');
unregister_widget('WC_Widget_Product_Categories');
unregister_widget('WC_Widget_Product_Tag_Cloud');
unregister_widget('WC_Widget_Cart');
unregister_widget('WC_Widget_Layered_Nav');
unregister_widget('WC_Widget_Layered_Nav_Filters');
unregister_widget('WC_Widget_Price_Filter');
unregister_widget('WC_Widget_Product_Search');
unregister_widget('WC_Widget_Top_Rated_Products');
unregister_widget('WC_Widget_Recent_Reviews');
unregister_widget('WC_Widget_Best_Sellers');
unregister_widget('WC_Widget_On_Sale');
unregister_widget('WC_Widget_Random_Products');
}
add_action('widgets_init', 'wp_dudecom_unregister_woocommerce_widgets', 15);
?>
Instructions
File Location: Add the provided code to your theme's functions.php
file or a custom plugin file.
Prerequisites:
- Ensure WooCommerce is installed and activated on your WordPress site.
Implementation Steps:
- Log in to your WordPress admin dashboard.
- Navigate to Appearance > Theme File Editor if you are adding the code to
functions.php
. Alternatively, open your custom plugin file if you prefer to use a plugin. - Locate and open the
functions.php
file from the list of theme files on the right side. - Scroll to the bottom of the file and paste the provided code snippet.
- Click Update File to save your changes.
- Refresh your WordPress admin dashboard to see the changes. The specified WooCommerce widgets should no longer appear in the dashboard or sidebar.
By following these steps, you can effectively declutter your WooCommerce admin area, focusing only on the widgets you need. If you require assistance with this implementation or need more advanced functionality, consider reaching out to wp-dude.com for expert help.