Including Magento blocks in a WordPress theme is straight forward, however, the internationalisation feature of both systems gets in the way.

An example

File 3 would throw: Fatal error: Cannot redeclare foo()

So, what’s the problem?

Put simply, they both have the same function. Whichever one comes first, PHP raises an error when the second one is defined. In the case of WordPress and Magento, they both have the function __.

How do I overcome this issue?

Deactivate a Magento function that conflicts with one in WordPress.

This is the easiest way to do it, as otherwise we’d need to modify core WordPress. Magento allows us to over-ride files using a “local” version.

The implemenation

Copy /app/code/core/Mage/Core/functions.php to /app/code/local/Mage/Core/functions.php – this file will now be used over the original, and will remain during Magento upgrades.

Open the file at /app/code/local/Mage/Core/functions.php and locate the function __ function. It should be around line 90, but can vary depending on your Magento version.

This should now become:

This tells Magento that it should only actually define the function if it’s not already been defined (by WordPress in our case).

So, how do I now include a CMS static block in my theme?

Image Credit: Ozgurmulazimoglu