- This topic has 7 replies, 2 voices, and was last updated 3 years, 4 months ago by
Tom.
-
AuthorPosts
-
September 13, 2019 at 11:06 am #1008871
Inga
Hi there,
I’m now searching for hours but I can’t find any template with the HTML of the WC-menu-item. I would like to add a custom hook right after the opening wc-menu-item-tag before the anchor-tag in my child theme.
There is no woocommerce-template either… What am I missing?September 13, 2019 at 3:36 pm #1008979Tom
Lead DeveloperLead DeveloperHi there,
That element is filtered into the menu items.
Where exactly are you wanting to hook into? After the menu item, or inside of it?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentSeptember 15, 2019 at 9:29 am #1010050Inga
Hi Tom,
thanks for your fast reply, I would like to hook inside the menu-item, right after the opening li-tag.September 15, 2019 at 7:28 pm #1010258Tom
Lead DeveloperLead DeveloperUnfortunately there is no hook in that location at the moment. I’ve added a note to look at adding one in GPP 1.9.
What are you trying to add there?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentSeptember 19, 2019 at 6:03 am #1013460Inga
I created a small conditional logged-in-menu with php (Hi [name], my account, logout) and I want it to be displayed left from the cart. No I inserted it with the inside-navigation hook, but I had to place it with css per “absolute”, so when the cart changes his width there is too much space.
No sure if there is a better solution…September 19, 2019 at 6:23 pm #1014070Tom
Lead DeveloperLead DeveloperAh, well we filter the wc menu item into the menu, so you can use the same method:
add_filter( 'wp_nav_menu_items', function( $nav, $args ) { if ( 'primary' === $args->theme_location ) { return sprintf( '%1$s <li class="your-menu-item-class"> Your menu item code in here </li>', $nav ); } return $nav; }, 5, 2 );
Let me know if you need more info ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentSeptember 23, 2019 at 3:33 pm #1017125Inga
Thank you, I’m new to filters and programming in general, so as I inserted your code there was a new menu-point added but I don’t know how to move it inside an existing one (the woocommerce-menu-point) what I originally wanted to do. It has to be inside so that I can place it correctly.
But now I see that even this won’t help me because in the mobile-version the cart-icon is added in a different way and my code would disappear.
I will do it with the “inside-navigation”-hook and try to position it as precise as possible with CSS.
Thank you very much anyway!
September 23, 2019 at 4:29 pm #1017154Tom
Lead DeveloperLead DeveloperI’ll see if I can add a filter in GPP 1.9 to make it easier to prepend/append items to the menu item ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.