There is a menu layout, you need to pull wordpress on it. This code creates only li tags in the ul list and displays the contents. And how in this code to add another tag "a" inside the tag li?

<ul class='list'> <?php if ( function_exists('wp_nav_menu')) { wp_nav_menu( array( 'theme_location' => 'custom-menu', 'fallback_cb' => 'custom-menu', 'container' => 'ul', 'menu_id' => 'nav', 'menu_class' => 'nav' ) ); } ?> </ul> 

functions.php:

 if( function_exists('register_nav_menus')) { register_nav_menus( array( 'custom-menu'=>__('Custom menu'), ) ); } function custom_menu() { wp_list_pages('title_li=&'); } 

Layout to be pulled:

 <ul class='list'> <li class='item'> <a href=''>Контакты</a> </li> <li class=''> <a href=''>О компании</a> </li> </ul> 
  • one
    Error, at least, in this line 'fallback_cb' => 'custom-menu', - the name of the function cannot be with a hyphen (and this function is declared with an underscore) - KAGG Design
  • @KAGG Design I changed the 'custom-menu' to 'custom_menu', the situation has not changed - Alexander

1 answer 1

Register menu (functions.php)

 function register_menus() { register_nav_menus(array( 'header-menu' => 'header-menu', 'footer-menu' => 'footer-menu')); } add_action( 'init', 'register_menus' ); 

Next, create a menu in the admin panel of Wordpress (Appearance> Menus), select the output location. Display the location in the right place for you:

wp_nav_menu( array( 'menu' => 'header-menu') );