This will show you how to add shortcodes to widgets in WordPress. Fortunately it’s really easy to do.
But first some terminology…
Widget areas are created by your theme, and allow you to add any number of widgets from Appearance >> Widgets.
Shortcodes are generally supported by plugins and look something like this: [wp-shortcode-here]
When the page is compiled the shortcode will be replaced by dynamic information that the software and the server will create.
What’s the problem with shortcodes in widgets?
Generally shortcodes are only added to posts or pages, and WordPress happily processes them.
However if you’ve ever tried to add a shortcode to a sidebar widget you would have discovered that exactly nothng happens.
For example I wanted to output my subscriber count from the MailPoet newsletter system into my sidebar widgets.
Join 685 other WP Tribe members now. Subscribe to the newsletter and instantly receive the beginners WordPress email course.
The number you see above is a dynamic value that is up to date thanks to the power of WordPress and PHP software.
How To Add Shortcodes To Widgets in WordPress
Open up your functions.php file inside your active theme, either in an FTP program with a text editor, or you can use a plugin such as WPide that allows you to edit your WP theme files directly.
NOTE: The FTP method is a safer way as it means you can still access your site if anything goes wrong. If you use the WPide way you need to be more careful.
Make a backup
Be sure to make a backup of your functions.php file first as this is a very important document that controls a lot of things with your theme.
Paste the code below into the bottom of your functions.php file inside your active theme folder.
// Allow Shortcodes in Widgets
FTP stands for File Transfer Protocol and put simply it’s just like the Explorer in Windows or the Finder in the Mac except you are accessing the files on your website server instead of on your local computer.
You will need to create an FTP account on cPanel or your server control panel first and then type in the details into your FTP client.
Some free FTP clients:
Now when you add shortcodes into your widgets, in the sidebar as a text widget or anywhere else your theme allows, it will be processed as correctly. No plugin required.