0

i've just begun participating these stack overflow forums yesterday and had a great experience with someone who could problem solve with me. working from the admin panel under the themes tab i have what looks like a working theme locations panel. i followed instructions i found for installing the proper php code in the proper functions.php file and then placed it where i wanted it to appear in the proper file for my theme. my issue is it won't actually function the way it was intended, i have 3 different menu's created but the site displays every page i created. i obviously slipped somewhere along the way but i can't find where.

here's what i have in my functions.php:

        add_theme_support( 'menus' );

add_action( 'init', 'my_custom_menus' );
function my_custom_menus() {
    register_nav_menus(
        array(
            'primary-menu' => __( 'Primary Menu' ),
            'secondary-menu' => __( 'Secondary Menu' )
        )
    );
}           

here's whats in my sidebar.php:

<aside>
    <div class="textBody">
    <div class="sideNav">
        <?php wp_nav_menu( array( 'theme_location' => 'extra-menu' ) ); ?>
    </div>
    </div>
</aside>

still learning, even posting on this site has a learning curve... thanks for reading this and any help or time is appreciated.

2
  • 1
    Please use proper Upper-/lowercase letters. That makes a much better reading experience. Thanks.
    – kaiser
    Commented Sep 13, 2012 at 12:55
  • @Ijan Hilaire Have you set menus in Appearance->menu in admin page? Commented Sep 13, 2012 at 12:58

1 Answer 1

1

Your menu name doesn't match in your sidebar. The theme_location should match the name of one of the registered menu's in your functions.php file.

Try replacing what you have with this:

For the functions.php file:

<?php
add_theme_support( 'menus' );
add_action( 'init', 'my_custom_menus' );
function my_custom_menus() {
  register_nav_menus(
    array(
      'primary' => __( 'primary' ),
      'secondary' => __( 'secondary' )
      )
    );
  }
?>

For the sidebar.php file:

<aside>
  <div class="textBody">
    <div class="sideNav">
      <?php wp_nav_menu( array( 'theme_location' => 'secondary' ) ); ?>
    </div>
  </div>
</aside>
3
  • hi jared, thanks for catching that the name didn't match. i've been trying to switch through the code to see what works and didn't return the names to a matching state. that said, the code you passed me still didn't unlock this side navigation. Commented Sep 13, 2012 at 6:13
  • Depending on your version of WordPress it might need to be placed inside of a after_theme_setup function/hook. See my answer to this question (the section labeled "the FIX" is what you should read). Let me know if that doesn't work or if you need more help. Commented Sep 13, 2012 at 7:30
  • hey jared, i'm sorry its taken days for me to respond but i had to abandon my original design and hope by modifying an existing theme i can satisfy my client. i'll back to revisit this issue as soon as i get this current project delivered or find time to finish resolving this issue. Commented Sep 18, 2012 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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