Take your website
To the next level
Discover our newly launched customization services and elevate your web projects to new heights.
Delegate tasks, save time, and unlock the power of professional WordPress outsourcing.

Okay
  Public Ticket #1233262
Change appearance or style menu item
Closed

Comments

  • Martin started the conversation

    Hello

    I want to add a link to the menu and give it a different appearance to the other items in the menu, that is to say it has another appearance and differentiates itself from the others like the image that I attached.

    I could indicate if there is a plugin or the best way to do it.

    Thank you

  •  433
    Sergio replied

    Hi,

    Pls. add follow code in functions.php your child theme

    function thegem_menu_item_button($items, $args){    if($args->theme_location == 'primary' && thegem_get_option('header_layout') !== 'overlay'){        $items .= '<li class="menu-item-button"><button class="gem-button">test</button></li>';    }    return $items;
    }
    add_filter('wp_nav_menu_items', 'thegem_menu_item_button', 50, 2);

    Then you can style this button

    If you’re happy with our theme, please rate us with 5 stars on Themeforest. It keeps us motivated!  (How to rate).

    Regards Sergio Codex.

  • Martin replied

    OK if it is what I need, but I modify the menu styles, when the sticky menu is activated the activated button does not show the total of the top of the button, attached images of its template

  •  433
    Sergio replied

    HI!

    pls. use following css:

    .site-header.fixed.shrink .nav-menu .menu-item-button .gem-button{
        margin:0 25px !important;
    }

     

    If you’re happy with our theme, please rate us with 5 stars on Themeforest. It keeps us motivated!  (How to rate).

    Regards Sergio Codex.

  • Martin replied

    Could you tell me where I put the button link in the code that you sent me

    I want to put the following link: http://www.htcsaludencasa.com/customer-area

    function thegem_menu_item_button($items, $args){    if($args->theme_location == 'primary' && thegem_get_option('header_layout') !== 'overlay'){        $items .= '<li class="menu-item-button"><button class="gem-button">test</button></li>';    }    return $items;
    }
    add_filter('wp_nav_menu_items', 'thegem_menu_item_button', 50, 2);


  •  433
    Sergio replied

    HI,

    pls. replace with the following code

    function thegem_menu_item_button($items, $args){
        if($args->theme_location == 'primary' && thegem_get_option('header_layout') !== 'overlay'){
            $items .= '<li class="menu-item-button"><a href="http://www.htcsaludencasa.com/customer-area" class="gem-button">Zona HTC</a></li>';
        }
        return $items;
    }
    add_filter('wp_nav_menu_items', 'thegem_menu_item_button', 50, 2);
    

    and use following CSS:

    .menu-item-button a{
        margin:0;
        display: block;
        width: 100%;
        height: 100%;
        background-color: #b80008;
        color:#fff;
        line-height:40px !important;
    }
    

    If you’re happy with our theme, please rate us with 5 stars on Themeforest. It keeps us motivated!  (How to rate).

    Regards Sergio Codex.