• Resolved alvaroprudente

    (@alvaroprudente)


    My nav menu in my theme is working strange:

    call:
    <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>

    url:
    2012.ficvaldivia.cl

    On the MainPage The Menu is built up perfectly…
    Now if I press on one button and go to another site away from home the background image (only on home or incicio) disappears.
    I actually use individual bg-images for every menu-item…
    Now I’m conscious that’s a css issue or an issue how the menu is built up.
    But my problem is that this menu item doesn’t get an own css-class so I do not now how to solve that.
    I tried to change the call to
    <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
    but this makes the problem worse, making only appear a bg-image on the current nav menu…

    When on “home”

    <nav id="access" role="navigation">
    								<div class="menu"><ul><li class="current_page_item"><a href="https://2012.ficvaldivia.cl/" title="Inicio">Inicio</a></li>

    When not on “home”

    <nav id="access" role="navigation">
    								<div class="menu"><ul><li ><a href="https://2012.ficvaldivia.cl/" title="Inicio">Inicio</a></li>

    So how can I give the inicio entry an INDIVIDUAL background image?

    Thx

    Patrick

Viewing 10 replies - 1 through 10 (of 10 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    To clarify;
    Is the problem you don’t know how to set a style to a current menu item?
    I don’t see what you mean.

    Thread Starter alvaroprudente

    (@alvaroprudente)

    Thx for the reply…
    Yes… and no…

    I don’t see a way to assigne to the menu entry inicio a unique bg-image as it seems to have no specific css-class.
    The rest of the menu entries has individual css classes so it’s quite easy to indivudually change the bg image. I’m strugglink with Inicio or Home, which via menu definition doesn’t get an individual css-class…

    Hope that’s clearer

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Will “inicio” always be the first menu item, or will “inicio” always have the same name?

    Thread Starter alvaroprudente

    (@alvaroprudente)

    always the first… and it has the same name, it’s the spanish translation of home…

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You could use jQuery to add a specific class to the first menu item, have you used jQuery before?

    Thread Starter alvaroprudente

    (@alvaroprudente)

    no, or indirectly via copy paste and other plugins…
    So I would need some starter help to do so…

    thx

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    In your footer.php file, above </body> add this

    <script type="text/javascript">
    jQuery(document).ready(function() {
     jQuery('.menu li a').first().addClass('home');
    });
    </script>

    Thread Starter alvaroprudente

    (@alvaroprudente)

    great aproach…

    unfortunately it doesn’t seem to change anything…

    <script type="text/javascript">
    jQuery(document).ready(function() {
     jQuery('.menu li a').first().addClass('home');
    });
    </script>
    </body>

    result:

    <tr><td colspan="2">
        			<nav id="access" role="navigation">
    								<div class="menu"><ul><li ><a href="https://2012.ficvaldivia.cl/" title="Inicio">Inicio</a></li>

    off course jquery is integrated in the header:
    <script type="text/javascript" src="https://2012.ficvaldivia.cl/wp-content/themes/19_ficv_wordpress_theme/scripts/jquery-1.7.2.min.js"></script>

    hmmmmmm……

    and I tried
    .menu ul li a
    too

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    It won’t be in your HTML, but the class is added.
    Try assigning a style to .menu li a.home

    Thread Starter alvaroprudente

    (@alvaroprudente)

    thanks… that worked fine!
    And I’ve learned something new…

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Problem with Nav Menu’ is closed to new replies.