The Problem

Shortcodes come with many plugins and are typically entered into the post or page editor using brackets like so: [example]

By default, shortcodes will not work if you put them into a text widget for use in the sidebar or another widgetized area. You can either install the “Allow Shortcodes in Text Widgets” plugin, or add a custom function file to your theme.

The Solution

Use a Plugin (beginners)

  1. Go to Plugins → Add New
  2. Search for “Allow shortcodes in text widgets”
  3. Install and activate the plugin

This is not an Obox plugin and it has not been updated by its author in several months. Install it at your own risk.

Create a Custom Function file (advanced)

By creating a custom functions file and placing it into the theme’s includes folder, it will load with the theme but be immune to theme updates. This is a great way to modify the theme with small functions without touching theme files. Note that deleting and reinstalling the theme will destroy your customizations, so please keep backups of any customizations you do.

  1. In a text or HTML editor, create a new file called myfunctions.php.
    • It is important you use an editor that can save the file in the correct format, ie the file cannot be myfunctions.php.txt
  2. Copy and paste the following code into the file, and ensure there are no blank lines at the beginning or end.
    	add_filter('widget_text', 'do_shortcode');
  3. Save the file and upload it via FTP to your web server under wp-content/themes/yourtheme/ocmx/includes/
  4. Your widget should now work with the shortcode.

Get a free Month with Flywheel Hosting