Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress WordPress Theme Development Building Out WordPress Navigation Coding A Basic Navigation in WordPress

Alfredo Prince
Alfredo Prince
6,175 Points

My menu isn't displaying at all. Any ideas?

When I click on my menu button it looks to just refresh the page.

Devon Pelletier
Devon Pelletier
9,255 Points

I'm also having this issue. Page refreshes on menu click, on every page. No errors in the console, menu is set up as Primary Menu, and I can see the menu when inspecting the page...

This is my code in functions.php:

add_theme_support( 'menus' );

function register_theme_menus() {
      'primary-menu' => __( 'Primary Menu' )
add_action( 'init', 'register_theme_menus' );

function wpt_theme_styles() {

  // Importing the CSS files
  wp_enqueue_style( 'foundation_css', get_template_directory_uri().'/css/foundation.css' );
  //wp_enqueue_style( 'normalize_css', get_template_directory_uri().'/css/normalize.css' );
  wp_enqueue_style( 'googlefont_css', 'http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic' );
  wp_enqueue_style( 'main_css', get_template_directory_uri().'/style.css' );

add_action( 'wp_enqueue_scripts', 'wpt_theme_styles' );

function wpt_theme_js() {
  wp_enqueue_script( 'modernizr_js', get_template_directory_uri().'/js/modernizr.js', '', '', false);
  wp_enqueue_script( 'foundation_js', get_template_directory_uri().'/js/foundation.min.js', array('jQuery'), '', true);
  wp_enqueue_script( 'app_js', get_template_directory_uri().'/js/app.js', array('jQuery', 'foundation_js'), '', false);
add_action( 'wp_enqueue_scripts', 'wpt_theme_js' );

And this is the menu php block in headers.php:

$defaults = array(
        'container' => false,
        'theme_location' => 'primary-menu',
        'menu_class' => 'no-bullet'

      wp_nav_menu( $defaults );

Any help is appreciated :)!

4 Answers

Alfredo Prince
Alfredo Prince
6,175 Points

Primary. I think it might be a js issue because I can see the menu items in inspector.

is their an error in the console? and in your backend, do you have your nav set up?

oh and is this a custom theme or a child?

To fix the page refresh issue I had to do add onclick="return false;" in the link tag.

example (line 13 in header.php):

 <a href="" class="nav-toggle" onclick="return false;"><span></span>Menu</a>

I tried putting return false in the app.js file like some ppl suggested, but it didn't fix the problem for me.

You do not need inline Js in the anchor tag. Are you enqueueing your menu in functions.php? Then in the backend setting the correct pages and menu?

Is there anyone who fixed this issue? I am seeing the correct output of menu when I am inspecting the website: Home, Portfolio, About and Contact Us. I know its JS issue, because when I click nothing pops up. The foundation.min.js is linked properly no errors are showing. There us return false already in my app.js file and I did try to put it in anchor tag as well, but didn't work for me. If you have any suggestions that would be greatly appreciated!

is this your primary nav, or a custom nav? if no nav is showing is it registered?