Magento WordPress Integration Magento WordPress Integration

Integrating WordPress Menu's

WordPress includes a great feature that allows you to build dynamic menu's based on your blog content directly from the WordPress Admin. This is a feature lacking in Magento so it's great that WordPress offers this. Using WordPress Integration, you can easily display any of these menu's in Magento and even append one to your main Magento navigation.

Add a Menu to the Main Magento Menu

If you're using an old version of Magento, this feature may not work. This feature will also only work if you using the default Magento menu system, as most custom menu's do not call the default menu events required.

The first step is to create a menu in the WordPress Admin. To do this, select Appearance > Menus and add the elements to your new menu. Once you have created the menu and saved it, login to the Magento Admin and select WordPress > Settings from the Admin menu. Scroll down to the section labelled 'Menu' and select your new menu from the pre-populated list. Assuming you have one of the later versions of Magento installed and are using the default menu system, your WordPress menu will have been automatically added to your Magento menu.

Add a WordPress Menu Anywhere in Magento

If your Magento navigation system doesn't use the default menu events, you can manually create a menu block using XML or PHP and include it your navigation template. This is also great for including lists of links in other places that you or your client want to easily control, such as footer links.

Create a menu in the WordPress Admin and take note of the ID that has been assigned to it. Assuming the ID assigned is 48, you can use the following code to create your menu block:

Using XML

<block type="wordpress/menu" name="wp.menu">
	<action method="setMenuId"><id>48</id></action>
	<action method="setListId"><id>my-menu</id></action>
	<action method="includeWrapper"><inc>1</inc></action>
	<!-- The above Includes the wrapping <ul tag -->
</block>

Using PHP

<?php $menu = Mage::getSingleton('core/layout')
	->createBlock('wordpress/menu')
	->setMenuId(48)
	->includeWrapper(true) // Includes the wrapping <ul tag 
	->setListId('my-menu') ?>
<?php echo $menu->toHtml() ?>

Using either of the above methods, you can take a WordPress menu and display it anywhere in your Magento website.

Post your comment

FishPig Ltd