Site logo

Archived topic

Adding custom HTML to nav menu

15 replies · Started by shai shmuel on June 5, 2018

Viewing posts 1–15 of 16

Hi all,

I added to my header Social media icons and google translator widget, for both of them I used the custom HTML widget, and later design it with the additional CSS.

My question is how can make it appear inside the menu?

Hi there,

you can use this Snippet to hook content inside the navigation and then style it with CSS to suit:

add_action( 'generate_inside_navigation','generate_insert_into_navigation' );
function generate_insert_into_navigation()
{ ?>
      Put your HTML or whatever in here
<?php }

Adding PHP: https://docs.generatepress.com/article/adding-php/

Hi David,

There is a way to do it without installing the plugin?

You can add it the code to a Child Theme function file.

I got confused a little bit...

I created a child theme and upload it, but I'm not sure about how to edit it properly.

Maybe I can use the GP Hooks?

Hooks are fine for adding content to be directly displayed in that position but not for adding actions. I would recommend the Code Snippets plugin, it's used by a lot of the GP community.

Hi David,

I downloaded the plugin and created a new snippet, and I got the following error: The snippet has been deactivated due to an error on line 2:

syntax error, unexpected 'insert_into_navigation' (T_STRING), expecting '('

there was an error in the code above, i have edited, please try again

Ok, I succeeded to do it.
But I have one problem the object appears 2 times.

Can you share a link to the site?

Yes, I took it off because it looks bad.

But I will bring it back right now so you will take a look:

https://tradeproperly.com/

Hi can you add the code back in so i can see the problem

The code is there. At right side on the Nav menu you will see the google translate widget

That widget is in the header widget area not the navigation. And i can't see two of them??

OK, It seems like only in my computer I can see it(?)
I checked the website from another computer and you are right The widget is not in the nav menu.

I don't know what is the problem.

This archived topic is closed to new replies.