0

good evening,

Im been having some kind of problem with a specific, and as far as I can see, simple WP project, specifically with how to use the wp_nav_menu function, normally, when I try to create a WP Menu I use something like this:

<?php wp_nav_menu( array('menu' => 'Main', 'container' => 'nav' )); ?>

And always use the same function on my functions.php document which is:

add_theme_support('nav-menus'); if ( function_exists('register_nav_menus')) {register_nav_menus( array('main' => 'Main Nav') );}

The thing is, when I try to use that code to convert my HTML menu into a WP menu nothing works, then, reading something I tried with this:

<?php wp_nav_menu( array('menu' => 'Main', 'container' => '', 'container_class' => '', 'menu_class' => '', 'menu_id' => '' )); ?>

But that missed a few things like icons on each button and the color which was gone as well, the menu in HTML is this one:

http://pastebin.com/n17C9Arv

So my question is basically, what am I missing?, why I'm not being able to reproduce the converted wp menu exactly like the html menu?

Driving me crazy....

Thanks guys!

Arturo

1 Answer 1

1

Greetings and thanks for posting on the forums.

If you want to register a single nav menu then use the function register_nav_menu instead of register_nav_menus as following to register it.

if ( function_exists('register_nav_menus')) {
    register_nav_menu( 'main', 'Main Nav' );
}

Note: The function register_nav_menu automatically registers custom menu support for the theme therefore you do not need to call add_theme_support( 'menus' );

To display navigation menu use the following code.

<!-- Navbar starts -->
 <div class="navi pull-right">
    <?php wp_nav_menu( array('theme_location' => 'main', 'container' => '<div>', 'container_class' => 'mattblackmenu', 'container_id' => 'ddtopmenubar' )); ?>
</div>

<div class="navis"></div>
 <!-- Navbar ends -->

Add the tag in the Navigation Label menu field to be displayed inside the anchor tag and bgreen class CSS Classes menu field as displayed in the attached screenshot.

If you are not getting "CSS Classes" menu field option then check the checkbox in the Screen Options as shown in the attached screenshot.

enter image description here

In your CSS code replace ".bgreen a" in place of ".bgreen" and .sub-menu in place of #ddsubmenu2 & .ddsubmenustyle if you have used any of these selectors in your CSS code.

You will find more information about parameters of wp_nav_menu() function on the following page.

http://codex.wordpress.org/Function_Reference/wp_nav_menu

Best Regards, Vinod Dalvi

11
  • Hi Vinod Dalvi thanks so much, however is not working completely properly, something is not working at all, I have 2 images of how it should look like, but using what you gave me I ended with a list menu and not the squares I should be using, but maybe I'm doing something wrong, do you know how to post pictures in comments? !Image.
    – Arturo
    Commented Jun 8, 2014 at 14:40
  • Here's an image of how it is looking and how it should look, not sure what i am doing wrong: !Example Image is Here
    – Arturo
    Commented Jun 8, 2014 at 14:58
  • Have you made changes in the CSS code as i have instructed? Commented Jun 8, 2014 at 16:35
  • 1
    Could you please share me your site link so that i can troubleshoot it? Commented Jun 8, 2014 at 16:36
  • Sure, the thing is, it has a maintenance mode on it, so I'd rather go and send that info privately, is there a way to do that?
    – Arturo
    Commented Jun 8, 2014 at 22:28

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.