clubmate.fi

A good[ish] website

Web development blog, loads of UI and JavaScript topics

Add support for WordPress custom menus

Filed under: WordPress/PHP— Tagged with: functions.php, php, snippets

Here's a quick snippet on how to add custom menus to WP.

This piece of code goes into your themes functions.php file:

add_action('init', 'register_navmenus');

function register_navmenus() {
  register_nav_menus(array(
    'Header' => __( 'Header Navigation' ),
    'Body' => __( 'Secondary Navigation' ),
    'Footer' => __( 'Footer Navigation' ),
    )
  );
}

Name the navigation items what is suits your use-case.

Comments would go here, but the commenting system isn’t ready yet, sorry.

  • © 2022 Antti Hiljá
  • About
  • All rights reserved yadda yadda.
  • I can put just about anything here, no one reads the footer anyways.
  • I love u!