Register Menu in WordPress -7

Register Menu in WordPress -7

In WordPress, menu can be registered using register_nav_menu functions and use hook after_setup_theme to support this

  • register_nav_menu (‘any Name’, ‘Human Friendly Name’)      

Registers a navigation menu location for a theme.

  • add_theme_support 

Registers theme support for a given feature. Like title, custom Logo etc.

  • after_setup_theme    

This hook is called during each page load, after the theme is initialized. It is here used for title, menu registration

<?php

//Function to register Menu and theme Support

function features()

{

    register_nav_menu (‘headerMenuLocation’, ‘Header Menu Location’);

    add_theme_support(‘title-tag’);

}

add action (‘after_setup_theme’, ‘features’);

?>

Steps to create menu in admin panel

Step 1: Open admin panel

Step 2: Click on Appearance

  • Open Appearance → Menus
  • Write Menu Name and Save
  • Drag and drop pages and change the order & hierarchy
  • Then click the display location from the Menu setting and Save
One thought on “Register Menu in WordPress -7

Post Your Comments & Reviews

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

*

*