Register nav menu for your custom theme in wordpress

register nav menu function code image

Register nav menu is necessary to function the navigation system. This function is important for your custom theme. We will learn the coding process of it. Please consider check my previous post on all the chapters related to this tutorial. Name of the post is theme development tutorial. Now, let’s start learning the necessary codes.

Login to your cPanel and open functions dot php file from theme folder. Then write down codes to function and activate the navigation section. First of all, we will create a new function for this. Let’s name it as (function your theme custom menu). Make sure about putting underscores after each word from your to menu. However, we will not put the underscore after function. Finally, the first step is done of this tutorial.

Now go for a first bracket and closing bracket for that. Then go for a second bracket and closing bracket for that. Consequently we will be coding in between the second bracket to make it functional. The first code is register nav menu for that. Again put underscores after each word. Consequently do the same while writing functions.

We will name that as my custom menu. So, write down first bracket (with ending bracket) again and my custom menu. Make sure putting hyphen after each word this time. Finally, our coding part is done for the function.

You can add your domain in the section. Therefore, the only part you need to add is double underscore, first bracket (with end) and name that as My Custom Menu. Make sure to write that in single inverted commas. Also, do not use any underscore or hyphen between words. Finally add action on it with first bracket. Code is ‘init’ for that. Then call the function name once again which is (your custom menu).