It’s pretty easy to add another custom menu to your WooCommerce pages via PHP. For example, you might want to add a list of Product Category links, and manage this through the default “Appearance > Menu” in the WordPress dashboard.
WP Dashboard > Appearance > Menu: create a new menu
Create a new menu called “Categories” and add the product categories you wish to it.
This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101
Related content
WooCommerce: Add Second Description @ Product Category Pages In terms of SEO, if you’re trying to rank your product category pages, you really need to make the most of the default WooCommerce product category “description” and “thumbnail”. Most themes, if compatible with WooCommerce, will show this content right below the product category name and above products. Nothing new so far. But what if […]
WooCommerce: Add Column to Orders Table @ WP Dashboard The WooCommerce Orders Table, which can be found under WP Dashboard > WooCommerce > Orders, provides us with 7 default columns: Order – Date – Status – Billing – Ship to – Total – Actions. This is used by shop managers to have an overview of all orders, before eventually clicking on a specific one. […]
WooCommerce: Display Custom Filters @ WP Dashboard > Products If you go to WordPress Dashboard > Products you will find default product admin filters such as “Select a category”, “Filter by product type”, “Filter by stock status”. What if you want to add more custom filters to let your shop managers find products easily? For example, you could add “Filter by product tag” (“product […]
WooCommerce: Hide/Show The WP Admin Bar In previous WooCommerce versions, new customers could access the WP Admin black bar after purchase. Now this seems fixed. Still, what about other user roles, and what if you want to override this default behavior? Well, here’s a quick snippet for you – feel free to use it in your own WooCommerce site. Enjoy!
WooCommerce: View Thank You Page @ Order Admin I’ve been testing for over an hour but finally I found a way to make this work. When you are in “Edit Order” view under WordPress Dashboard > WooCommerce > Orders, there is a dropdown of “Order actions”: “Email invoice”, “Resend new order notification”, etc. A major problem I’ve always had while troubleshooting or working […]
Rodolfo Melogli
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli
8 thoughts on “WooCommerce: Add WP Menu to WC Pages via PHP”
Samuel
Hi, thanks for your help. I tried but I received this answer from wordpress
Uncaught Error: Call to undefined function avia_get_header_scroll_offset() in wp-content/themes/enfold/css/dynamic-css.php:1005
Stack trace:
#0 wp-content/themes/enfold/includes/admin/register-dynamic-styles.php(159): require()
#1 wp-content/themes/enfold/functions.php(696): avia_prepare_dynamic_styles()
#2 wp-includes/class-wp-hook.php(287): avia_custom_styles('')
#3 wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array)
#4 wp-includes/plugin.php(478): WP_Hook->do_action(Array)
#5 wp-settings.php(540): do_action('init')
#6 wp-config.php(89): require_once('/web/htdocs/www...')
#7 wp-load.php(37): require_once('/web/htdocs/www...')
#8 wp-admin/admin.php(34): r
I guess your code is causing a conflict with my theme? I’m using Enfold Theme
Questions? Feedback? Customization? Leave your comment now! _____
If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!
Hi, thanks for your help. I tried but I received this answer from wordpress
I guess your code is causing a conflict with my theme? I’m using Enfold Theme
I guess so
THANK YOU for this! But Can I add a class to this? I want it to match my header menu with this same class:
Where would I insert the code to make it pull this one instead?
Hey Kimberly thanks for your comment! If you take a look at https://developer.wordpress.org/reference/functions/wp_nav_menu/, you can see you can also declare a parameter called “menu_class”. That should help ๐
Hi Rodolfo,
Thanks for the code!
Is there a way to tweak this further, if we need a separate custom menu for each product?
Hey Shruti, thanks for your comment! Yes, of course, you could take a look at my conditional logic guide to see how to target a specific product ID: https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/
Thank you for the code ๐
De nada ๐