Créer une nouvelle zone de menu WordPress

Modifier le fichier funtions.php situé dans /wp-content/themes/NOM_DU_THEME/functions.php, enregistrer le menu et sa position via la fonction register_nav_menu()

Exemple:

register_nav_menus( array(
	'pluginbuddy_mobile' => 'PluginBuddy Mobile Navigation Menu',
	'footer_menu' => 'My Custom Footer Menu',
) );

Utiliser la fonction wp_nav_menu() à l’emplacement souhaité dans le thème pour afficher le menu

 <?php wp_nav_menu( $args ); ?> 

Arguments:

<?php

$defaults = array(
	'theme_location'  => '',
	'menu'            => '',
	'container'       => 'div',
	'container_class' => '',
	'container_id'    => '',
	'menu_class'      => 'menu',
	'menu_id'         => '',
	'echo'            => true,
	'fallback_cb'     => 'wp_page_menu',
	'before'          => '',
	'after'           => '',
	'link_before'     => '',
	'link_after'      => '',
	'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
	'depth'           => 0,
	'walker'          => ''
);

wp_nav_menu( $defaults );

?>

Exemple:

<div id="menu" role="navigation">
    <?php wp_nav_menu(array('theme_location' => 'header')); ?>
</div>

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *


2 × deux =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>