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.

Using Paid Memberships Pro Shortcodes in Widget Banner Image

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.

Shortcode in PMPro Widgets

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.

Free Course: Membership Site Development—The Basics

Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.

Featured Image for Membership Site Development Course: The Basics
Was this article helpful?
YesNo