How To Add A Logo Image To Any Nav Menu

In this post, i’ll show you how to add a logo image to either your primary or secondary navigation menu.

You’ll also be able to float your logo to the left or right of your menu items.

On top of this, you can easily change the position your image sits in your menu.

logo menu genesis

Here’s the PHP & CSS code you need to add at the end of your child themes functions.php & style.css files.

PHP Code

Change the primary theme location to secondary if you want to add your logo in your secondary nav menu.

You’ll also need to upload your image to your media library in WordPress and change the url in the code to your own.

CSS Code

Change the float: left; declaration to float right to display your logo to the right of your nav menu items.

If your image is smaller than the height of the nav bar, you can center it by adding some margin-top:

.nav-logo {
float: left;
margin-right: 20px;
margin-top: 20px;

Works equally as well in the Twenty Twelve & Twenty Thirteen default themes for WordPress.

twenty thirteen theme logo nav menu

2012 image in menu

Using Logo From Images Folder

If you prefer to add your logo to your child themes images folder, you can use this code as another alternative:

Link Your Logo From Images Directory

You might also want to link your image which you can do by using this code as another alternative.

The advantage of using this code is that you can easily change the home_url to any other url template tag and even include a path relative to the home url.

Another Option

You can also use this code to add an image to any nav menu in any WordPress theme.

Note: You will also need to add the sample CSS included in this post which may need modifying depending on which theme you’re using.

Other Cool Stuff You Can Do With Your Logo

Register To Get Full Access & Support

Also get instant access to all premium content & downloads.

Members of WP Sites get:

  • Answers to questions relating to code & tutorials
  • Support for installation & modification of code
  • Solutions & advice given to you directly via email
  • Cancel subscription at any time, no questions asked

$65 $27/month (Early Bird Rate Limited Time Only)

1 Start Here: Enter Your Details
2 Submit PayPal Payment


  1. Amber says

    Hi Brad,

    I’ve got the logo sitting where I want it to in the nav bar now, but like the commenter above, I want to make the logo hyperlink back to the front page.

    I’ve tried the code you replied with above but don’t understand exactly where to add my URL and the image address. Can you please help? Thanks.

    add_filter( 'wp_nav_menu_items', 'wpsites_add_logo_nav_menu', 10, 2 );
    function wpsites_add_logo_nav_menu( $menu, stdClass $args ){
        if ( 'primary' != $args->theme_location )
            return $menu;
        $menu .= sprintf( '<a href="' . esc_url( home_url( '/' ) ) . '" rel="nofollow">%s', __( '') );
        return $menu;
  2. first says

    Hi Brad,

    Thanks for the code, it works perfectly.
    But I would like to create an grey hover effect when I pass the mouse on the logo, how do I do that please?


  3. tom says

    I am trying to put a larger image than the height of the Nav Bar, The Nav Bar is adjusting to make up for the space, now I have a very high nav bar, is there a way to keep the nav bar the same height, but have the image over hang on the top and bottom?

    • Brad Dalton says

      Hello Michelle

      Code updated: Simply add your logo.png image file to your child themes images folder and use this code.

      This is not the only way to code this function.

      You could use a different class so it validates for W3 Standards (which i will do and update the code) and you could print the HTML for the image differently.

      Then add list-style-type to the declarations like this:

      .nav-logo {
      float: left;
      margin-right: 20px;
      margin-top: 20px;
      list-style-type: none;

      And that now validates for W3.

      • Michelle says

        Hi Brad,

        Thanks so much for addressing this so quickly! I’m a little unclear on what you’re saying about validating for W3, however. Are you suggesting using the code you just provided with the modified CSS (the one that includes list-style-type: none;) or are you saying that the function would need to be different altogether to validate for W3?

        Also, I’m trying to ensure that when I insert the logo in the navigation menu, it remains to the left of all of the other links in the menu (like the sample images you show). But currently, the logo seems to jump to a second line below the other links in the menu if there are too many items in the menu or if the page size is reduced. How can I tell the function to load the logo first and always make it the first item at left in the menu?

        Thanks again for all of your help!


        • Brad Dalton says

          You can skip that part as i i have updated the code and tested it.

          There’s many different ways to write code that does the same thing.

          PHP is only one side of the solution but doesn’t tell the browser where to output the HTML so you also need to add CSS.

          Its impossible to provide CSS code that works on every theme as there’s 1000’s which are all coded differently.

          I can only provide sample CSS which may need tweaking and/or additions of extra declarations.

          Little bit of work on your behalf is required.

          Watch out for a new post which includes another option for the CSS in a similar solution.

          Something like this may work if you change some of the values:

          .search-form {
          position: absolute;
          right: 105px;
          padding-top: 15px;
          width: 360px;
          list-style-type: none;
          • Michelle says

            Hi Brad,

            I apologize if I was unclear. The search field is fine and the logo is lining up on the left side. But, for some reason, the logo is showing up on a second line below the other menu items. Basically, I’m trying to get the logo to show at the beginning of the menu (the first item with subsequent menu items aligned to the right of the logo).

            How do I make the logo the first to display in the list rather than the last (as it currently is)?

            I understand that CSS is theme/site specific, but this seems like something that should be inserted in the function to tell the logo where to load within wp_nav_menu_items.

            Thanks again for all of your help!!


  4. Julie says

    Thank you for this tip.
    However in my twenty thirteen chip theme, my logo goes to the right of the navbar instead of left.
    What do you think I can do, to put it on the left ?
    Many thanks!

  5. Joyce Grace says

    Something I really want to try is turning the logo into an SVG, importing that into the IconMoon app, making it part of an icon-font set and then resolving the retina display problem that way. The thing I haven’t tested yet is whether the CSS class on the WordPress menu item would work. I tried inserting a character code into the “Navigation Label” area of a WordPress Menu but that didn’t work, it won’t accept it. I should try a div in that area…a while ago HTML worked in Page Titles….hmmm….

    This would not work with multi-coloured logos but would be a really great solution for one-colour logos….

Leave a Reply