Wednesday 2 November 2011

How to add shortcodes in wordpress sidebar text widget?


In wordpress we have a nice concept called shortcodes. A shortcode is WordPress-specific codes that will do the things in an easy way. We have several default shortcodes and a shortcode will be inserted in a post or page file by embedding square braces.

Once I got a requirement to add the shortcode in the sidebar. So I just edited the sidebar.php file and added shortcode in the sidebar. As a developer I know how to add the code in the file so i can do it in that way. This notes is for the one who does not know how to embed the code.  For this add the following line of code to your theme functions.php file.

add_filter('widget_text', 'do_shortcode');

Enjoy using the shortcodes


No comments:

Post a Comment