- Hikaru {Aka} Yuuki のブログ - http://www.hikaruyuuki.com/en -

Enable Shortcode in WordPress’ Widgets and Comments

This post is also available in: Indonesian [1]

Sometimes we need to use shortcodes in the widgets or comments. One example of using shortcode in the Widget is to create a different style to specific word in the Widget Title, by putting the word in the span tag. This span then later given a different style via CSS. Example is below.

[2]

Shortcode di Widget

To enable shortcode in Widgets, add lines below in file function.php inside your theme folder.

add_filter('widget_title', 'do_shortcode');
add_filter('widget_text', 'do_shortcode');

Shortcode di Comment

While to enable in comments, add line below.

add_filter('comment_text', 'do_shortcode');