0
votes

I've looked around for this but can't seem to find a definite answer. I want to know where WordPress shortcodes are supported within the (self-hosted) platform - meaning where can I safely place shortcode content and expect it to be rendered? I know I can use them in post and page content, and some widgets that output something. But can I use them in other plugins (that also output something), and which widgets are supported? Do custom plugins need to have something enabled that allows them to render shortcode content?

This page says:

By default, WordPress does not support shortcodes within Sidebar Widgets. It only expands the shortcodes within the content of a Post, Page, or custom post type.

... although I've gotten shortcodes to work in the arbitrary text widget, so that information doesn't seem accurate. It also suggests I install this plugin that hasn't been updated in years.

Is there any clarification somewhere on this that I've missed?

1

1 Answers

0
votes

You can use:

<?php do_shortcode('name_of_shortcode'); ?>

e.g echo do_shortcode('[gallery autoplay=no]');

and it will render this shortcode. You can place it in functions.php, header.php, footer.php.

EDIT:

If you want it to work in Text Widget, all you need is to add this line of code in functions.php file:

add_filter('widget_text', 'do_shortcode');