Archived topic
Add PHP code to menu item
6 replies · Started by Amos on March 16, 2017
Hello. i want to add a php code to menu item (primary) it is possible?
Hi there,
What are you trying to add? It maybe easier to use a plugin like this: https://wordpress.org/plugins/if-menu/
Let me know.
i want to add the first code :
https://docs.woocommerce.com/document/show-cart-contents-total/
inside menu item.
i dont want to use 3rd party plugin for this.
I don't think that code is for you to add to the menu as it says it's for template.
This is probably what you are looking for: https://en-ca.wordpress.org/plugins/woocommerce-menu-bar-cart/
Let me know if this helps.
It's not possible to add PHP to menu items.
You would have to turn the PHP into a shortcode, then use a plugin like this: https://en-ca.wordpress.org/plugins/shortcode-in-menus/
Thank You Tom and Leo. i am using the code inside the "After Header Content" Hook and it is look good also.
Tom there is any update about the woocommerce add on ? :)
Nothing new yet :)