This is just a quick run through on how to execute a shortcode from within a WordPress Widget and place it in your sidebar…OR…call the widget into a post and display it on the post (using a shortcode in the post itself).
This is VERY POWERFUL as it extends the ability to use plugins that run off shortcodes in your posts easily. You can really run shortcodes within shortcodes quite easily too if you are really hardcore…and even use an executable php or code widget quite easily right in an post…but let’s keep it simple to start…
Running a Shortcode in a Widget
This involves a minor edit to your functions file…which you can see on this post about using shortcodes from WordPress Widgets. They have also posted a method to call a widget from a post…but the other functions coding they referenced wasn’t working quickly for some reason, so knowing there was a plugin for this…I chose the plugin method instead…so use the plugin method below to call a widget from the post itself as it is an ace to administrate. (below is the code they reference)
Place This Code Inside Your functions.php widget
Without the <code></code> bits
- You can place this right in your functions file after sidebar declarations without php tags
- There is probably a plugin that does the same thing, but this procedure is pretty simple
Now On To The Awesomeness…
Call a WordPress Widget From a Post
The Widgets on Pages Plugin uses shortcodes to call a widget zone into the page or post. You can setup as many widgets as you need…and have multiple different widgets and zones I believe, but I only have tried one so far.
Update: Have tried many instances on same page and it works great.
The article I was reading in the WordPress Codex referenced another plugin called Page Blocks which sounded pretty neat…although, it wasn’t tested due to not being listed as current on versions…but one unique feature was displaying a message upon a visitor returning from PayPal…I may end up giving this a try too even though it doesn’t seem to be supported anymore from the developer site for page blocks.
Some cool things you can do with these (and these combined)
- Call a Plugin Function to be Used in a Post (with Shortcodes) from a Sidebar Widget
- Execute PHP Within a Post (with a PHP Exec Widget)
- Call Shortcodes from Within Shortcodes (Inside a Post) (Multi-Level)
- Display Existing Widgets from Plugins or WP in the Page/Post
You can Also…
Easily Grid Out CSS Zones in the Page or Post with the Easy Columns Plugin
Also read this post for how to insert jQuery tabs, toggles and accordians into a post with really nice theming.
(this is awesome as it runs on shortcodes…and then you can put other shortcodes within the grid codes and pretty much create small widget zones in the post (or full magazine style layouts for general use)
Tested with WordPress 3.2.1 and 3.3.1 (check for updated status on plugin repository as other versions come out for compatibility)
Photo Credit to greggoconnell for Ghetto Superman