WordPress menu with option of pages and category

-1

I'm learning how to do WordPress themes and seeing tutorials how to make menu calls in Wordpress.

I saw several tutorials on how to call category and page menu, but I'm not finding a tutorial on how to create a menu that calls them both, since I see many websites that have this option.

Is there any tutorial on how to do this? I'm starting to build themes, but I've been running WordPress sites for some time.

    
asked by anonymous 16.04.2014 / 21:53

2 answers

1

The best way to work with menus in WordPress themes is to use the native function, at times it is no longer necessary to use functions of type

  

wp_list_categories ()

for the menus, then let's go.

First you need to enable menu support in your theme, so insert the code below into the functions.php of your theme:

  

if (function_exists ('add_theme_support')) {       add_theme_support ('top');       add_theme_support ('rodape'); }

Done this in your theme you will use the codes below to display the menus where you want:

wp_nav_menu( array('menu' => 'topo' ) );
wp_nav_menu( array('menu' => 'rodape' ) );

Now just go to the Appearance > Menus in the administrative page of your theme, click on create new menu, there you will select top or footer and choose which pages and categories should be part of the menu. In practice it's very simple.

    
19.04.2014 / 02:08
1

Thanks Leo, I'll study this method too.

I've seen the codex in this way

no functions I put it like this:

if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(
array(
'header-menu' => 'top menu',
)
);
}

and on pages like this.

<nav id="menu">
        <?php
        wp_nav_menu(array(
        'theme_location' => 'header-menu', // aqi vc seleciona o menu que vc registrou
        'container' => 'nav',
        'container_id' => 'nav',
        'container_class' => 'nav-teste',
        'menu_id' => 'menu',
        'menu_class' => 'menu',
        'echo' => true,
        'before' => '',
        'after' => '',
        'link_before' => '',
        'link_after' => '',
        'depth' => '0',
        ));
        ?>
    </nav>

Thank you.

    
21.04.2014 / 16:55