Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have been using this code to display my wordpress navigation and it worked;

<ul id="menu">
<?php wp_list_pages('sort_column=menu_order&title_li='); ?>
</ul>

However,i want to use register_nav_menus so that i can arrange my menus from the wp backend.I have this code and its not working as expected;

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

My menus html should looks like this

    <ul id="menu">
    <li><a href="http://localhost">Home</a></li>

    <li>
        <a href="#">Pages</a>
    </li>
    <li>
        <a href="#">Portfolio</a>   
    </li>

    <li>
        <a href="#">Admin UI</a>    
    </li>
    <li>
        <a href="#">Features</a>    
    </li>
    <li>
        <a href="#">Shortcodes Wp 3.3</a>
                <ul>
                    <li><a href="#">Typography</a></li>
                    <li><a href="#">Sliders</a></li>
                    <li><a href="#">Columns</a></li>
                    <li><a href="#">Buttons</a></li>
                    <li><a href="#">Typography</a></li>
                    <li><a href="#">Sliders</a>
                    <ul>    
                    <li><a href="#">Typography</a></li>
                    <li><a href="#">Sliders</a></li>
                    <li><a href="#">Columns</a></li>
                    <li><a href="#">Buttons</a></li>
                    </ul>
                    </li>
                    <li><a href="#">Columns</a></li>
                </ul>               
    </li>
    <li>
        <a href="#">Blog</a>    
    </li>
    <li>
        <a href="#">Cute</a>    
    </li>
</ul>
share|improve this question
    
...and its not working as expected — what exactly did you expect and what is it doing otherwise? could you edit your question and clarify that? –  its_me Jul 15 '12 at 16:38
    
I expected my ul to have the id menu.I looked at the function on codex and discovered the menu_id parameter.Its now working well.I shall answer the question after 8 hours. –  Gandalf Jul 15 '12 at 16:42
add comment

2 Answers

Try this instead:

wp_nav_menu( array('menu' => 'Main menu' ));

Make sure you have a menu called 'Main menu'

share|improve this answer
    
This worked for me - <?php $defaults = array( 'menu_id' => 'menu', 'echo' => true, 'fallback_cb' => 'wp_page_menu' ); ?> <?php wp_nav_menu( $defaults ); ?> –  Gandalf Jul 15 '12 at 16:46
    
@flapjack Plz delete the comment and write your own answer, so that we can upvote and you can mark it as the answer after 2 days. :) –  its_me Jul 16 '12 at 8:25
add comment

I solved it this way

<?php $defaults = array( 'menu_id' => 'menu', 'echo' => true, 'fallback_cb' => 'wp_page_menu' ); ?>

 <?php wp_nav_menu( $defaults ); ?>

I was missing the 'menu_id' => 'menu' id.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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