Does anyone know why when I the code to implement the menu it displays the menu right after the body tag.

And this is where I add my code

<div class='nav'>
    <a href='#' class='menu_btn'>Menu</a>
    " . wp_nav_menu(array('theme_location'=>'primary')) ."
  • Are the lack of PHP tags on purpose? <?php wp_nav_menu(...); ?>
    – Howdy_McGee
    Sep 25 '15 at 20:54
  • Yes because its inside an echo. Maybe that is causing the problem?
    – user68181
    Sep 25 '15 at 22:23
  • By default wp nav menu echos itself
    – Howdy_McGee
    Sep 25 '15 at 22:24
  • Yes but I cant use php tags because I already used echo at the top
    – user68181
    Sep 25 '15 at 22:58
  • And you can't use this as it is because 2 echos don't make a right. Look at the Codex and see if that helps.
    – Howdy_McGee
    Sep 25 '15 at 23:00

You need to add the echo argument so that function returns the menu:

wp_nav_menu( array( 'theme_location'=>'primary', 'echo' => false ) )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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