× Please, log in to give us a feedback. Click here to login

You must be logged to download. Click here to login


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

How to create MenuBar in WordPress

See in this article how to create a menu bar in wordpress cms. The WordPress documentation is supporting to add menu to admin pages and this procedure is controlled via admin_menu action hook.

Now a day’s one very popular term in our software development world that is Content Management System (CMS). It is one of the most popular administration systems at a glance. Menu creation is one of the most popular parts for building a well define website. Some built-in-menu function is used to solve different types of issues such as adding and removing menu items.

It is one of the simple process to add menu item in our webpage is that go to the administration panel with the add_menu_page () function which can take some arguments.

Now I am discussing some features of menu in Word Press.

  • The text which is displayed in the title of the webpage
  • The text that is capability to define for allowing access to the menu item.
  • A menu casing identifier that identifies this menu from any other in the system.
  • A function that renders the page through the browser of the website.
  • The path to access an icon that is displayed with menu and also accessing data.
  • The position that the new menu item is set that has a relation to other menu items.

First of all you need to install the package in your host, if you don't know how to do this, you can see here how to install wordpress.

Place the following code in init.php for generating menu in the website.

Listing 1: Sample showing init.php file

add_action("admin_menu", "addMenu");
function addMenu() {
    add_menu_page("Contact Us", "Contact Us", "edit_posts",
  • The code will generate a new page link which sits at the top of the menu structure, just above the Dashboard:
  • But, consider the following implementation of addMenu() instead:

Listing 2: Sample showing addMenu function

function addMenu() {
add_menu_page("Menu","Menu","edit_posts","srimenu", "displayPage",null, 2);}

WordPress generates a global array that is called $menu which is used to store menu configuration. Every key in the array representation represents the position in the menu.

Step by Step procedure to Create Menu:

At first login the Wordpress Administrator option using following link as shown below: http://localhost/phpsrimani/wordpress-3.7/wordpress/wp-admin/

 Login in your account

Figure 1: Login in your account

Go to Dashboard- > Select Appearance - > Select Menu as shown below.

Creating Menu

Figure 2: Creating Menu

Then Click Create a new menu- > Give a name - > After giving the name click on Create New as shown below:

Giving Name to Menu

Figure 3: Giving Name to Menu

After creating the menu we can easily update, delete of our webpage menu. One point should be remembered that hyperlink must be set properly because using the hyperlink procedure we can easily use to link one page to another page. But if this hyperlink is not set properly then an abnormal error will be generated and no correct page will be displayed for correct menu setting. So after creating the menu we have to go to the URL position and set proper URL to communicate to the page as shown below.

Editing Menu Structure

Figure 4: Editing Menu Structure

After creation of the page, we just open the page and we can easily see that our website display the page with properly given menu order. WordPress also support to set proper order of the menu. So it is one of the advantages to set our website menu with totally customized design choice as shown in one sample below.

Testing Menu

Figure 5: Testing Menu

Identifying the Custom Menu Order in Word Press:

We know that WordPress is used for menu configuration. We can use the menu control to perform this operation. Generally Word Press provides two types of filter this filter are menu_order and custom_menu_ order.

This custom_menu_order is an important factor for a Boolean value expression that returns a custom menu. That is used to return value from custom_menu_order and also filter is applied.

The custom_menu_order filter always return an array that detailing the slugs of the menu in the appropriate order.

Now we are writing a code that design for custom menu order.

Listing 3: Sample showing custom menu addition

add_filter("custom_menu_order",   "allowMenuStructure");
//add_filter function passing two parameter like //custom_menu_order,allowMenuStructure the definition is written below
add_filter("menu_order", "loadMenuStructure");
//add_filter function passing two parameter like //menu_order, loadMenuStructure the definition is written below
 function allowMenuStructure() {
    //it is returning statements 
return true;
 function loadMenuStructure() {
	//it is returning array like index.php and tools.php
    return array("index.php", "tools.php");

Process to Creating a Custom Menu Manager:

In the WordPress we have a power to switch the custom_menu_order filter that is used to settle the menu in the desired order by storing an array in WordPress. This part is used to be returned when this filter is applied in WordPress.

Generally we can update our system or create that we call later with get_option().

WordPress stores all types of data in the database table by using wp_options.

The first thing we should do is add your own menu item so that you can administer the menu order. The returned value from add_menu_page() is a “hook suffix” which you can append to a number of action hooks which are specific to the page. The one we are interested here is load-page_hook where page_hook should be substituted with the hook suffix.

These pointers need to be remembered to add our own menu item that we can use to administer the menu order. The returning value from the add_menu_page() is called as “hook suffix” that we can append to a number of action hooks that are specific to the page. The hook suffix is substituted with page_hook.

This hook is an ideal place to process form submissions as it will only occur when this page is loaded.

Determining Location for New Menus:

When we are creating a new menu then we have to decide that this menu should be a top-level in the webpage or a sub-level menu item in the webpage. The top-level menu always displays a new section in the administration menus and also contains sub-level menu items as proper process. The sub-level menu item is a member of an existing menu in the webpage.

Some time it is important that a plugin would require the construction of a top-level menu. The plug-in shows an entirely innovative concept or an important feature of WordPress. It needs for many screen development. After that the plugin may permit a new top-level menu. Adding a top-level menu, we can considered when we surely need multiple related screens to make WordPress.

If we find out that creation of a top-level menu is not necessary for our webpage then we have to decide under what top-level menu to place our sub-level menu item. WordPress can spontaneously create sub-level menus under the applicable top-level menu to control menu item feature.

Here we discuss some guidance for top-level menus to define the correct position for our sub-level menu item:

Sl.No Items Application
1 Dashboard This part is responsible for set data to central for our site and includes the Updates option for updating WordPress core, plugins, and themes as our choice.
2 Posts This item is using to displays tools for writing posts (Basically it is time oriented content).
3 Media This media item is responsible for the Uploading and managing our pictures, videos, and audio files.
4 Links This is link items it manage references to other blogs and sites of interest.
5 Pages It is define as displays tools for writing our static content that is generally called pages.
6 Comments This item is controlling and regulation reader to responses to posts.
7 Appearance It is an appearance items for displays controls for manipulation of theme/style files, sidebars, etc.
8 Plugins It is an item that switches dealing with plugin management but it is not configuration options for a plugin itself.
9 Users It is a user item that displays controls for user management.
10 Tools This tools item Manage the export, import system and smooth backup of blog data.
11 Settings This setting option to displays the plugin choices it is an security level that only administrators should view.
12 Network Admin It is network administrative part that displays plugin options that are set on the Network.

Admin Menu Functions:

Now we think that to join our top-level or sub-level menu and the next step is to communicate WordPress about our new pages that create in the website. All of them will take place in a function registered to the 'admin_menu' action.

Top-Level Menus:

When we think that our plugin requires a brand-new top-level menu the first thing we will need to create one with the add_menu_page function. This point should be remembered that skip to Sub-Menus if you don't need a top-level menu.

A function will display here with following parameter values.

Parameter values:

  • page_title
  • menu_title
  • capability
  • menu_slug
  • function
  • icon_url
  • position

Listing 4: Sample showing parameter values

add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); 

Sub-Level Menus

If your Sub-Level Menu is defined and it is required to define one or more sub-level menu items using the add_submenu_page function. You have to guarantee to add the sub-level menu items in the order that we are considering for making wonderful website.


Menu is a one of the most important design part in the Webpage design programming. Because using the menu base process, we can set different types of hyperlink that support to link one page to another page. We now know that WordPress is a Content Management System so menu driven procedure support is a common part of CMS. From the above discussion we know the actual procedure to support Menu base system in Word Press. Hope you have enjoyed the article.

Website: www.techalpine.com Have 16 years of experience as a technical architect and software consultant in enterprise application and product development. Have interest in new technology and innovation area along with technical...

What did you think of this post?
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!

> More info about MrBool Credits
You must be logged to download.

Click here to login