• Is there a way to include an image with just the home link in my nav?

    I wish the logo for my site to be a part of the home link (they both have the same destination). I will then position the image absolutely about the nav, but gain the advantage of them both being a part of the same anchor tag.

    I do not wish to use javascript, I’d like to hard code this or use the menu register variables.

    Thanks for your time

Viewing 11 replies - 1 through 11 (of 11 total)
  • A link to your site might help.

    Thread Starter cmcp

    (@cmcp)

    Hi Esmi thanks for replying. It might help, but I am not in a position to post the link at the moment.

    I’m using out the box functionality of twentyten.

    <ul><li ><a href="https://www.example.org" title="Home">Home</a></li>

    is the standard html spat out by the template.

    I need to know if it is possible to spit out

    <ul><li ><a href="https://www.example.org" title="Home">Home<img src="image.gif" alt="" /></a></li>

    only on the home link. I do not need this on any of the other links.

    Is this possible? I’m looking in the functions and menu-nav-template but can’t see a hook.

    Thread Starter cmcp

    (@cmcp)

    Essentially I want to add an image after the opening <a> (using the $after parameter?) but only if the link is home.

    What are you using to create the links. That doesn’t look like the output from wp_page_menu or wp_nav_menu to me.

    Thread Starter cmcp

    (@cmcp)

    In my TwentyTenChild theme (which is just a copy of TwentyTen) I use this line <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?> that spits out the code above.

    In the absence of a custom menu, wp_nav_menu falls back to using wp_page_menu which, in turn, produces quite different markup to the example you gave above. Posting a link to your site might help here.

    Thread Starter cmcp

    (@cmcp)

    Are you sure? Because I have another demo site running TwentyTen and it is spitting out that exact markup too.

    I will set up a demo.

    This article may be useful to read: https://wpfirstaid.com/2010/10/extend-the-wordpress-menu/

    It explains how to add menu items/output to the beginning and/or the end of the wp_nav_menu() output.

    Thread Starter cmcp

    (@cmcp)

    I think what I may be best doing is to build up a home link with the $homelink variable, something like $homelink = '<li class="home"><a href="' . home_url( '/' ) . '"><img src="#" alt=""/>' . __('Home') . '</a></li>';

    Thanks for the link Edward, I shall give that approach a try.

    Thread Starter cmcp

    (@cmcp)

    I was able to use the standard WP menus feature in the admin area to build up my top level navigation, with the home link as

    <li><a href="#">Home<img src="#" alt=""/></a></li>

    Thank you for all your help ??

    i have the solution. kindly tell me whether you are using custom menu

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘menu nav, include image in "home" anchor’ is closed to new replies.