If you want to use a Paid Memberships Pro shortcode in a widget, your theme must declare support for shortcodes in widget_text
. In this code recipe, we share a single line of code that you can use to customize your site so shortcodes can be used in widgets.

Table of contents
Which Shortcodes Will this Apply To?
The short answer? All of them. This snippet will allow the use of pages shortcodes outlined in Memberships > Page Settings or the membership required shortcode to optionally reveal specific content based on membership level.

The Code Snippet
// Use shortcodes in text widgets. add_filter( 'widget_text', 'do_shortcode' );
Adding the Recipe to Your Website
You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.
If you’ve tried to add a shortcode to a widget and it isn’t working as intended, you can copy add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.
For more help and information on the filter used in this tutorial check out the WordPress developer handbook’s documentation on the do_shortcode
function.