Enrique Moreno Tent
Enrique Moreno Tent

Reputation: 25237

enable menu in Wordpress 3 themes

Im a wordpress noobie.

Im making a new Wordpress theme. Im using version 3.3.1. I've read that for making menus I should use the "Menu" section of each theme:

http://awesomescreenshot.com/01atql42e

But when I activate my own theme I CREATED, that option is not present.

http://awesomescreenshot.com/0f0tqmhc6

What am I missing?

Upvotes: 6

Views: 10939

Answers (2)

Matt
Matt

Reputation: 570

Seeing as how you say you're inexperienced with coding, I've prepared some pieces of code for you to insert into your functions & header files, but I recommend you look at how they were created so that you get a bit more familiar with Wordpress' functions. Like thenetimp said, you'll have to add menu support for your theme which can be done with the function add_theme_support('menus'), afterwards, you can register multiple menus with the function register_nav_menus( %menu array% ), with an array of menus inside the function, like this:

add_theme_support( 'menus' );
if ( function_exists( 'register_nav_menus' ) ) {
    register_nav_menus(
        array(
          'header-menu' => 'Header Menu',
          'footer-menu' => 'Footer Menu'
        )
    );
}

This function adds theme support for menus, as well as adds the individual menus 'Header Menu' & 'Footer Menu,' which can be called in your theme. To do this, you can use the function wp_nav_menu( %menu name% ). Whatever you put for 'menu name,' Wordpress'll look for that menu in your site's database, and show its contents. So, if you wanted to call that header menu we made earlier, you could use the code in your header.php file:

 <?php wp_nav_menu( array(
                            'theme_location' => 'header-menu',
                            'container' =>'nav',
                            'menu_class' => 'menu header-menu'
                          )
                    ) ?>

This code will get the menu from the location 'header-menu', wrap it in a nav element, and give it the class 'menu header-menu' (which can be helpful when styling your menu). I've only shown a couple of options so that you don't get confused, but if you're curious, you can find out more over at Wordpress' documentation site (link)

Upvotes: 6

thenetimp
thenetimp

Reputation: 9820

Wordpress changed the code in 3.0 that generates the nav you are probably using the old code. The new functionality is described in the codex here.

http://codex.wordpress.org/Function_Reference/wp_nav_menu

You also have to include this in your functions.php

add_theme_support( 'menus' );

Here's a good tutorial.

http://millionclues.com/problogging/wordpress-tips/make-your-theme-wordpress-3-0-compatible/

Upvotes: 9

Related Questions