Custom location for menu

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

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

error code: 523