Get Menu ID by Theme Location

Get Menu ID by Theme Location

Sometimes we have to build up our menu settings by own HTML layout where wp_nav_menu or nav-menu-walker function becomes harder than our capability. To avoid those kind of situation we like to havewp_get_nav_menu_items($menuID); where if you pass the ID you will get a set of array-object to display menu layout in front nicely.

Now, question how we will get the ID to get the set of menu-list. Here is my tutorial for you to get that Menu ID by theme location.

Formula-1: If you want only the ID the simply follow below function-

Formula-2: If you need menu ID, menu name, menu slug, etc then you can use below function



Formula-3: If you want to get all Menu Information that has been created by users through admin menu settings, then you can follow below code


Formula-4: If you want to get Menu ID by Menu Name that has been created by users through admin menu settings, just follow simple rules

That’s all. Still if you face any problem to get your solution. Feel free to drop a message, hope we can sort out your problem.


This post has already been read 3583 times!

Mehedi Hasan

Cool WordPress Developer having much agile experience to develop any kind of WordPress sites & plugins. Also good in troubleshooting, fixing & making any kind of tweaks for WP site.

More Posts

POSTED ON: Wordpress Development

Leave a Reply

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