Fishpig’s WordPress supports shortcode too. This allows Magento to render shortcodes in Full Integration mode. However, the rendering code in Fishpig is independent from official WordPress. Therefore the official shortcodes do not work when rendering in Magento. Fishpig supplied a separated set of shortcode for the full integration.
But what if you need to support a custom WordPress shortcode in Magento? Well, this is the tutorial for you!
Example: Global Content Blocks
In the following example, I’ll be implementing the shortcode for Global Content Blocks.
Note: This example assumes you know how to create a Magento extension.
There are 2 steps involved. The first is to declare your shortcode and the second step is to hook up your shortcode to the “wordpress_shortcode_apply” event observer. Please see the follow gist for details.
This implementation only supports multi-site setup and basic content rendering. It takes both numeric and string as identifier. However, it does not support advanced features such as PHP eval and %%variables%% rendering, which supported in WordPress version. Those pieces of content should be rendered as plain text. You have to add extra logic to support these advanced features.
This concludes the tutorial. Please leave a comment if you have any questions. The next part of the series will be “Adding WordPress Posts and Categories to Magento’s Google Sitemap”.