How to add a custom link in WordPress admin menu for WooCommerce orders
If you’re running a WooCommerce store, you know how important it is to have quick access to your orders. By default, WooCommerce orders are located a few clicks away, but what if you could add a custom link named “Orders” directly in your WordPress admin menu? This guide will show you how to add a custom link right above the “Posts” section in your WordPress dashboard, making it easier to manage your store.
This adjustment can save you time, streamline your workflow, and make managing your WooCommerce shop much more efficient!
Why add a custom link for WooCommerce orders?
By adding a custom menu item in the WordPress admin panel, you:
- Get faster access to your WooCommerce orders.
- Simplify the workflow for you and any other admins or store managers.
- Enhance productivity by reducing the time spent navigating the WordPress admin panel.
Step-by-step guide to adding a custom menu link
Important: Before you proceed, it’s crucial to edit your child theme’s functions.php
file instead of your main theme’s file. This prevents your changes from being overwritten when your theme updates.
If you don’t have a child theme set up, follow these steps to create one:
- Create a new folder in your WordPress
wp-content/themes/
directory. Name it something likeyourtheme-child
(replace “yourtheme” with the name of your active theme). - Inside this new folder, create a
style.css
file with the following content:/* Theme Name: Your Theme Child Template: yourtheme */
Replace “Your Theme Child” with your desired name and “yourtheme” with the folder name of your active theme.
- Create a
functions.php
file in your child theme folder. This file will be used for your custom code.
Adding the custom link code
- Log in to your WordPress admin panel.
- Navigate to Appearance > Theme File Editor.
- Select your child theme from the dropdown menu and open the
functions.php
file. - Add the following code to your child theme’s
functions.php
file:<?php function custom_admin_menu() { // Add a new menu item before the "Posts" link add_menu_page( 'Orders', // The page title 'Orders', // The menu item name 'manage_woocommerce', // The required capability (adjust if necessary) 'edit.php?post_type=shop_order', // The link URL '', // Callback, not needed here 'dashicons-cart', // Icon (optional) 4 // Menu position (4 places it above "Posts") ); } add_action('admin_menu', 'custom_admin_menu'); ?>
How this code works?
- The
add_menu_page()
function creates a new menu item named “Orders.” - The
manage_woocommerce
capability ensures that only those with the right permissions can access this menu item. - The
edit.php?post_type=shop_order
directs the link to your WooCommerce orders page. - The
'dashicons-cart'
icon gives it a visual touch that matches WooCommerce.
Benefits of using a WordPress child theme
- Preserve Customizations: Your changes will not be lost when you update your main theme.
- Flexibility: You can continue to modify other elements of your WordPress theme safely.
Why this works great with WooCommerce?
This customization is particularly useful if you’re using WooCommerce – the most popular eCommerce plugin for WordPress. By default, WooCommerce offers many options, but quick access to orders is crucial for running a successful store. This hack enhances the WooCommerce experience, making your admin panel more user-friendly and efficient.
Learn more about WooCommerce and why it’s the best eCommerce plugin for WordPress here.
Tips for advanced customization
- You can change the
manage_woocommerce
capability tomanage_options
if you want only site admins to access this link. - Modify the
4
position value to adjust where the link appears in your admin menu.
Troubleshooting
If the link doesn’t appear:
- Ensure you are editing your child theme’s
functions.php
file, not the parent theme’s. - Check for syntax errors.
- Make sure WooCommerce is installed and active.
- Verify your user role has the
manage_woocommerce
capability.
Conclusion
Adding a custom WooCommerce orders link in your WordPress admin menu is a simple yet effective way to improve your store management experience. By using a child theme, you ensure that your customization remains intact even after updating your main theme. This small tweak can make a big difference in how efficiently you manage your orders.
Don’t forget to regularly update your theme and WooCommerce plugin to ensure everything continues to run smoothly. Try adding this link today and make your WordPress dashboard work for you!