0

I am trying to add a variable inside wp_nav_menu, I am not sure how to do it, please help me! Here is a snippet of the code:

wp_nav_menu(array(
                'menu' => 'Main Menu',
                'theme_location' => 'Main Menu',
                'container' => null,
                'container_class' => '',
                'menu_id' => 'header-menu',
                'menu_class' => '',
                'before' => '<span class="text1">',
                'after' => '</span><span class="text2"><a href="">' . the_title($post->ID) . '</a></span>',
            ));

PLEASE HELP ME!

3 Answers 3

2

Is this what you mean? You may have to explain a little further, but this is how you'd add some additional values to wp_nav_menu.

wp_nav_menu(array(
            'MyItem' => 'My Value',                 // <--new item
            'MyotherItem' => 'My Other Value',      // <--other new item
            'menu' => 'Main Menu',
            'theme_location' => 'Main Menu',
            'container' => null,
            'container_class' => '',
            'menu_id' => 'header-menu',
            'menu_class' => '',
            'before' => '<span class="text1">',
            'after' => '</span><span class="text2"><a href="">' . the_title($post->ID) . '</a></span>',
));
Sign up to request clarification or add additional context in comments.

1 Comment

so basically I need my html to come out like this <li> <span class="text1"><a href="/about">ABOUT</a></span> <span class="text2"> <a href="/about">OUI</a> </span> </li>
0

Have a look at this tutorial. It's quite likely to answer your question and more

Comments

0

Try this this will add URL

wp_nav_menu( array( 'theme_location' => 'header-menu','menu_class' => 'drop', 'container' => 'nav', 'link_before' => '<span></span>') );

If you want it this way url

 wp_nav_menu( array( 'theme_location' => 'header-menu','menu_class' => 'drop', 'container' => 'nav', 'link_before' => '<span>', 'link_after' => '</span>') );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.