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

shareyourpeace
shareyourpeace
3,244 Points

Why do I have Two Menus ? One as shown in the video and one on the left side of the frame ?

I resolved this in another project but now I have the same issue.

Following the video exactly.... or so I believe.

I did an inspect element to show the html/css for the div that appears on the left side of the window.

Can someone interpret and explain why this element shows up ?

Thanks

http://imgur.com/icE0Urd

From the code you sent to Zac, remove the following from above the closing nav in the header.php

<?php wp_nav_menu(array('theme_location' => 'primary-menu'))?>

The above code inserted may be the reason for having 2 navs.

2 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi,

Can you post up the code that you're using for your header.php and the page template please. My guess is that it's a widget menu displaying, but without seeing the code it's tough to know. When you update your widgets does it change things. You can also look through your code to see if you are using wp_nav_menu more than once.

shareyourpeace
shareyourpeace
3,244 Points

Thanks Zac :) Yes, I am using wp_nav_menu 2x.
I believe that is how it is coded in the video and both lines of code are different. They seem to be required but I am not certain at this point.

header.php

<!doctype html>
<html class="no-js" lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title><?php wp_title(' | ', 'true', 'right'); bloginfo('name'); ?></title>

    <!--enqueue styles and scripts functions are called here with wp_head(); -->
    <?php wp_head(); ?>
  </head>

  <body <?php body_class(); ?>>
    <header class="row no-max pad main">
  <h1><a class='current' href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>
  <a href="" class="nav-toggle"><span></span>Menu</a>

  <nav>
    <h1 class="open"><a class='current' href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>

    <?php 
    $defaults = array(
        'container' => false,
        'theme_location' => 'primary-menu',
        'menu_Class' => 'no-bullet'
        );

    wp_nav_menu($defaults);
    ?>

    <!--
     <ul class="no-bullet">
      <li class="parent"><a href="index.html">Portfolio</a>
        <ul class="sub-menu">
          <li><a href="item.html">Portfolio Item</a></li>
          <li><a href="item.html">Portfolio Item</a></li>
          <li><a href="item.html">Portfolio Item</a></li>
          <li><a href="item.html">Portfolio Item</a></li>
        </ul>
      </li>
      <li class="current parent"><a class='current' href="blog.html">Blog</a>
        <ul class="sub-menu">
          <li><a href="single-post.html">Single Post</a></li>
          <li><a href="author.html">Author Page</a></li>
        </ul>
      </li>
      <li><a href="about.html">About</a></li>
      <li><a href="contact.html">Contact</a></li>
    </ul>
    -->

        <?php wp_nav_menu(array('theme_location' => 'primary-menu'))?>
  </nav>
</header>

page.php

<?php get_header(); ?>
    <section class="row">
      <div class="small-12 columns text-center">
        <div class="leader">

            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

            <h1><?php the_title(); ?></h1>
            <p><?php the_content(); ?></p>

            <?php endwhile; else : ?>
                 <p><?php _e( 'Sorry, no page found.', 'my_portfolio'); ?></p>
            <?php endif; ?>         
        </div>
      </div>
    </section>

<?php get_footer(); ?>

page-sidebar-left.php

<?php
/*
 * Template Name: Left Sidebar
 */
?>

<?php get_header(); ?>

<section class="two-column row no-max pad">
      <div class="small-12 columns">
        <div class="row">
          <!-- Primary Column -->
          <div class="small-12 medium-7 medium-offset-1 medium-push-4 columns">
            <div class="primary">

            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

            <h1><?php the_title(); ?></h1>
            <p><?php the_content(); ?></p>

            <?php endwhile; else : ?>
                 <p><?php _e( 'Sorry, no pages found.', 'my_portfolio'); ?></p>
            <?php endif; ?>
            </div>  
        </div>
        </div>

          <?php get_sidebar('page'); ?>
    </div>
</section>

<?php get_footer(); ?>
Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

So, you're echoing out wp_nav_menu twice in your header.php. Is that on purpose?