[Support request] Adding custom HTML to nav menu

Home Forums Support [Support request] Adding custom HTML to nav menu

Home Forums Support Adding custom HTML to nav menu

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #592215
    shai shmuel

    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?

    #592224
    David
    Staff
    Customer Support

    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/

    #592310
    shai shmuel

    Hi David,

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

    #592391
    David
    Staff
    Customer Support

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

    #593781
    shai shmuel

    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?

    #593825
    David
    Staff
    Customer Support

    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.

    #593899
    shai shmuel

    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 ‘(‘

    #593933
    David
    Staff
    Customer Support

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

    #594870
    shai shmuel

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

    #594928
    David
    Staff
    Customer Support

    Can you share a link to the site?

    #596416
    shai shmuel

    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/

    #596491
    David
    Staff
    Customer Support

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

    #596503
    shai shmuel

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

    #596515
    David
    Staff
    Customer Support

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

    #596691
    shai shmuel

    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.

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.