0

I have been assigned with the task to create a menu that can be added or removed from wordpress admin. Right now the menu is hard coded into the templates. But I want to use default menu function wp_nav_menu and the menu should look exactly like before.

But trying for the whole day i cannot figure how to make the menu using wp_nav_menu and look exactly like the menu item currently having in this site. I can make the menu using wp_nav_menu but the menu is looking like a mess and not like this.

1
  • 4
    wp_nav_menu will will create HTML. You need to format it with CSS. Without seeing the broken menu if possible and the code it is hard to say much else.
    – s_ha_dum
    Commented Nov 6, 2012 at 16:02

1 Answer 1

0

In your theme's functions.php, write the following code:

<?php
/* ENABLING CUSTOM MENUS
-------------------------------------------------- */
//add_theme_support( 'menus' );

    register_nav_menus(
        array(
        'primary'=>__('Primary Menu'),
        'secondary'=>__('Secondary Menu'),
        )
    );
?>

It'll register two custom menu area for your theme.
Then you need to achieve it with in header.php:

<?php wp_nav_menu ( array ( 'theme_location'=>'primary', 'fallback_cb'=>'') ); ?>

This code will place only the Primary Menu area in your theme.
Now you need to code the CSS, and These whole bunch of code is really amazing! I found it from a tutorial site.
Try it and then modify it as per your need, and then find the author of the code (not me) and thanks him. :)

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.