How do I get a menu item by ID in Joomla 3?

While converting a site from Joomla 1.5 to Joomla 3, I encountered this code

$mainframe = JFactory::getApplication(); 
$menu = $mainframe->getMenu('mainmenu'); 
$item = $menu->getItem($Itemid);

How to achieve this in Joomla 3 ?

1 Answer 1


Not a big difference so far for what you are after...

$mainframe = JFactory::getApplication(); 
$menu = $mainframe->getMenu(); 

// Use this if you want to get all menu items from a certain menu
$menu_items = $menu->getItems('menutype', 'mainmenu');

// This is to get the specific menu item by menu item Id $itemId;
$item = $menu->getItem($itemId);

Check also, this Q/A, on getting the active menu item: How to get the alias or title of the active menu item?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.