Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1414211

    infaroe
    Participant

    How do I add an image that points to an url, on the navbar located just behind the search button to the right?

    I have tried with the css style (.background-image) but I don’t know how to put an hyperlink to it (Guess it only works with html codes)
    So I’ve also tried with an html code (put an html code to the _navbar child theme). But there I don’t know how to place it right behind the search button 😀

    Hope you can help – Thanks!

    #1414775

    Paul R
    Moderator

    Hi,

    Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    #1415229

    infaroe
    Participant

    Its brudleyp.fo – and I want a small english flag image just behind the search button on the navbar, that I will link to an english page.

    #1415859

    Friech
    Moderator

    Hi There,

    You already have a child theme right? Please open and edit your child theme’s functions.php file and add the code below:

    function x_navbar_flag_navigation_item( $items, $args ) {
    
          if ( $args->theme_location == 'primary' ) {
            $items .= '<li class="menu-item x-menu-item x-menu-item-flag">'
                      . '<a href="URL OF YOUR ENGLISH PAGE" class="x-btn-navbar-flag">'
                        . '<img width="24px" height="24px" src="IMAGE URL HERE" />'
                      . '</a>'
                    . '</li>';
    }
        return $items;
    
      }
      add_filter( 'wp_nav_menu_items', 'x_navbar_flag_navigation_item', 9999, 2 );

    Replace the URL OF YOUR ENGLISH PAGE with the link of your English page, and the IMAGE URL HERE with the actual flag image URL. Make sure your flag image is relatively small.

    Hope it helps, Cheers!

    #1422158

    infaroe
    Participant

    Thanks Friech, its working perfectly 🙂

    #1422308

    Friech
    Moderator

    We’re delighted to assist you with this.

    Cheers!