How to add shortcode means how to make shortcode runnable when paste in a widget section.
Most advice on this converges to this simple line of code:
add_filter('widget_text', 'do_shortcode');
Though a wide spread method, this is not quite correct. The more correct way would be:
if (!is_admin())
add_filter('widget_text', 'do_shortcode', 11);
if (!is_admin()) add_filter('widget_text', 'do_shortcode', SHORTCODE_PRIORITY);
to avoid guessing what the number 11 means, but
SHORTCODE_PRIORITY
is a constant the WordPress team has yet to provide.
No comments:
Post a Comment