Magento / WordPress Integration WordPress Shortcodes

To make it easier for site Administrators to add dynamic content to their WordPress blog posts, WordPress introduced shortcodes. A number of the more popular WordPress shortcodes work with FishPig's WordPress Integration, as well as some new shortcodes, only available in the extension!

Check the list below for what shortcodes are available and how to use them.

Display a Magento Product In WordPress

The product shortcode is a custom shortcode only available in FishPig's WordPress Integration that will allow you to include a Magento product inside your WordPress blog post.

Basic Usage

If you know the ID of the product you want to include, you can do so by pasting the following shortcode into your WordPress blog.

[product id="4"]

Changing the Template

By default, the product shortcode uses the 'wordpress/shortcode/product.phtml' template. This is a general purpose template that displays the product name and image. If you need more information, use the following code to change the template to one of your own choosing.

[product id="4" template="wordpress/shortcode/custom-product.phtml"]

When setting a custom template, make sure that the template actually exists, otherwise nothing will be displayed!

Display Associated Magento Products in WordPress

This is another shortcode that is only available through FishPig's WordPress Integration. Using this shortcode in a blog post will list all of the products associated with the current post.

Basic Usage

[associated-products]

By default, the associated products shortcode uses the 'wordpress/shortcode/associated-products.phtml' template. To change this, see below.

Changing the title

[associated-products title="You might be interested in..."]

Changing the template

[associated-products template="wordpress/shortcode/custom-associated-products.phtml"]

When setting a custom template, make sure that the template actually exists, otherwise nothing will be displayed!

Embed a Youtube Video in WordPress

Using FishPig's WordPress Integration, it is possible to embed Youtube videos in the exact same way that you can when running WordPress normally, however, we offer even more options! See the examples below to figure out how best to embed Youtube videos on your site.

Basic Useage

[youtube="http://www.youtube.com/watch?v=DhtcaRRngcw"]

Using the above shortcode with embed a video of the Johnny Cash song, 'When the Man Comes Around'. This will embed the video at the default size (480 x 385)

Setting Custom Dimensions

To get the video looking just right for your blog, you may want to change the height and width. To do so, use one of the following shortcode examples.

Setting the Youtube Video Width

[youtube="http://www.youtube.com/watch?v=DhtcaRRngcw&w=600"]

Notice the &w=600 in the URL? This will set the youtube video width to 600 pixels.

Setting the Youtube Video Height

[youtube="http://www.youtube.com/watch?v=DhtcaRRngcw&h=600"]

Notice the &h=600 in the URL? This will set the youtube video height to 600 pixels.

Setting the Youtube Video Width & Height

[youtube="http://www.youtube.com/watch?v=DhtcaRRngcw&w=600&h=400"]

Notice the &w=600&h=400 in the URL? This will set the youtube video width to 600 pixels and the youtube video height to 400 pixels.

Disabling Related Videos

When an embeded Youtube video has finished playing, it will usually display several videos related to the embeded video. While this is great for a user, it provides an increased risk of the user leaving your site. Fortunately Youtube make it quite easy to disable related videos.

[youtube="http://www.youtube.com/watch?v=DhtcaRRngcw&w=600&h=400&rel=0"]

Here we have added &rel=0 to the Youtube video URL. This will stop the related videos form displaying.

Remove The Youtube Search Bar

Also when a Youtube video has finished playing, a Youtube search box will be displayed, providing another way for your user to leave your site. To remove this search box, use the shortcode example below.

[youtube="http://www.youtube.com/watch?v=DhtcaRRngcw&w=600&h=400&showsearch=0"]

The showsearch=0 parameter isn't needed when the rel=0 parameter is set as this removes the search box as well.

Autoplay An Embeded Youtube Video

Adding the autoplay parameter will automatically start the video when the page has finished loading.

[youtube="http://www.youtube.com/watch?v=DhtcaRRngcw&w=600&h=600&autoplay=1"]

Adding the Gallery Shortcode

The gallery shortcode provides an easy way to add multiple images into your posts. Although still under development, the majority of features for this shortcode are available and can be used in FishPig's WordPress Integration v1.8.25 and above. For more information on this plugin, please see the WordPress Codex.

Gallery Styling

The easiest way to style the gallery is to copy the gallery related styles directly from WordPress. Alternatively, you can just add your own CSS to your Magento stylesheet.