I like the Thesis theme–a lot. And that multimedia box in Thesis is incredibly handy to display all kinds of fancy blogging goodness. But what if you’ve got a plugin with WordPress shortcodes that you’d love to call in the MM box? Shortcodes, in case you didn’t know, extremely handy shortcuts that you can either create or are created by some WP plugins that let you insert stuff painlessly, by adding something like [myshortcode parameter="variable"] to include your specially generated content. Shortcodes work in the sidebar using the default WP text widget, so it would be natural to expect them to work in the MM box, right?
Not exactly. If you optimistically try plugging the shortcode in the Thesis custom multimediabox code, you’ll be disappointed in short order. It doesn’t work out of the box. But with a little PHP code, you can indeed weave some MM Box magic and be happily on your way. [1]
Adding your Custom Shortcode Function
To get your shortcode parsed, you’ll need to set up a custom function. Don’t be scared. It’s not as hard as you may think.
Using the OpenHook Plugin
OpenHook plugin for Thesis is like the lazy web developers’ way to add custom functions. Hop into your OpenHook, and put something like this in the MultiMedia Box area:
<?php $myfunction= '[your-shortcode-here]'; $myfunction_parsed = do_shortcode($myfunction); echo $myfunction_parsed;?>
Make sure you check the “Execute PHP” checkbox under this code snippet in OpenHook, since…well, you want it to execute the PHP. Duh.
Without the OpenHook Plugin
You can still easily achieve this without the OpenHook plugin; you’ll be wrapping your code snippet in a function and adding it to your custom_functions.php file directly. With Thesis 1.6+, you can even edit the custom_functions.php in the Thesis options from the WP admin. How’s that for convenient?
We’re looking at something like this: [2]
<?php
function custom_mm_shortcode() {
$myfunction= '[your-shortcode-here]';
$myfunction_parsed = do_shortcode($myfunction);
echo $myfunction_parsed;
}
add_action('thesis_hook_multimedia_box','custom_mm_shortcode');?>
Displaying Your New Multimedia Box Shortcoded Content
Now that you have your custom function set up commanding Thesis to parse your shortcode in the MM box, you need to call it. To display your shortcode content on any individual post or page, go down to the Multimedia Box options and check the “Access Multimedia Box Hook” checkbox. Pretty darned simple, don’t you think?
If you want the multimedia box to default to your special shortcode–still allowing you to override it on a case-by-case basis–then you need to go into the Thesis Options, Design Options. You’ll be setting your the default to “Custom Code” and leaving the box empty, as pictured.
There. That wasn’t so bad, was it?
Note: This tutorial only allows for one shortcode to be selected for the multimedia box display. Feed your need for higher flexibility with WP Conditionals.
Footnotes- Thanks to Rick B. for this easy fix to include shortcode in the MM box. [↑]
- Please: If you see a problem with my code, mention it in the comments so I can correct. I am not a programmer; I am a hack. [↑]
Possibly Related
Posted on November 16, 2009 at 4:19 pm in: WordPress





{ 1 trackback }
{ 0 comments… add one now }