You can try the following:
/**
* Only allow shortcodes for a widget with a given title.
*
* @see http://wordpress.stackexchange.com/a/160246/26350
*/
function wpse_widget_shortcode( $text, $instance )
{
// Only allow shortcodes for the widget with the following title:
$title="Some Title";
remove_filter( current_filter(), __FUNCTION__ );
if( isset( $instance['title'] )
&& mb_strtolower( $title ) === $instance['title']
)
$text = do_shortcode( $text );
return $text;
}
add_filter( 'widget_text', 'wpse_widget_shortcode', 99, 2 );
where we target the given widget by it’s title.
Related Posts:
- Shortcode from a widget is wrapped in unwanted element
- How can I whitelist only specific shortcodes for processing in text widgets?
- When to use which plugin output method?
- Custom shortcode in widget forced to top of widget
- Shortcode in Text Widget not working
- Inserting shortcode [stream /] into a Text widget
- check for shortcode in post/pages AND widgets AND template files
- the_widget() and widget’s ID
- How the widget can be run by shortcode
- How do i display the built-in gallery inside a widget?
- Shortcode displays always first. Once again
- Create a widget to use shortcode?
- Check if the current shortcode is being used in a widget
- Display custom widget, added as a shortcode in the correct place
- Shortcode not working in widget
- call widget from within shortcode
- Transform php shortcode into a widget [duplicate]
- Can I use widgets & shortcode if I need to return an array?
- page url in shortcode
- How do I get shortcode, widget and template tag CSS to load in the head only as required? [duplicate]
- Translate widget titles using qTranslate plugin
- How Do I Add Custom CSS To Only Certain Widgets
- How to add Custom Fields to Settings in Widget Options for all Registered Widgets?
- link wordpress and stackoverflow
- Copy widget settings from one blog to another
- Sidebar Widget Registration without a name, how is it assigned to new named sidebar widget?
- How to Make a Custom Dashboard Widget to Display Custom Notification from Admin?
- Add thumbnail to recent posts widget using filters
- Is there a way to allow only certain type of widgets in the sidebars?
- Why wordpress popular post widget shows Undefined index?
- How to enable / use new video / audio / images widgets in WordPress 4.8?
- Latest/Recent posts widget title link
- Insert Widget option into mark-up with register_sidebar
- Widgets not expanding on wordpress 3.3 widget dashbord
- Removing default theme widgets
- List monthy archives for specific year with wp_get_archives
- wp_register_sidebar_widget() disappered my Widgets submenu – what am I doing wrong?
- Display single widget
- different class (css) for sidebar widgets
- Adding widgets with Featured Image via the Customizer run hundreds of queries
- Adding a Widget : what to put in plugin URL
- How to list all custom post types in a custom widget?
- How can I assign widgets from WP to appear in bbpress?
- get_option returns undesired blank instance of a widget
- escaping and sanitizing input for custom widget form fields
- Dynamic created widget id value of multi-instance in jQuery
- Text widget doesn’t save the content
- Post ID displayed instead of title [closed]
- How to select multiple media files for a widget form?
- Create an extra Widget Areas in WordPress TwentyTwelve
- How do I pass the id of my widget to javascript in the form function?
- Default widgets assignment – isn’t working
- wp_get_attachment_image() not displaying post images even though wp_get_attachment_url() echo correct urls
- Add Shortcode tag in Widget/Sidebar
- what is the best way to add things to a side bar
- Disable a plugin’s widget
- How to add urls in html widget in a gravity form? [closed]
- How to add custom tinymce plugin to new text widget
- What widgets are used on a page? [closed]
- Create Dashboard Widget with form to keep team’s record
- How not to display an instance of a widget dynamically?
- Twenty Twelve Widget Taking Space
- Conditional widget_form_callback
- Any advice on customising this twitter feed?
- How to use variables from widgets in other pages?
- Change number of widget columns in dashboard?
- How do I add a small excerpt of a blog post on my Front Page Recent Posts widget?
- WordPress 5.8 : display new widget
- Determine if a specific Gutenberg block is used on pages/posts
- Use atributes of shortcode in get template part
- Mobile view: how to remove right/left margin from the specific widgets?
- Sorting Tag Cloud by Popularity
- My theme didn’t appear sidebar area
- How to create sidebar from “scratch”?
- wp_list_widget_controls() undefined
- Render repeatable widget fields properly with Backbone.js
- Script in sidebar blocks other widget’s load
- WordPress version quick check?
- Can I get variable into dynamic sidebar?
- How to show a widget for logged-in users only?
- Can’t output the number 0 in widget
- widget exclude post by custom field
- how to call new widgets in sidebar in custom theme?
- Modify the siderbar footer
- Run an action only when Widget actually instantiated (not just registered)
- My blog has a design issue.
- Call sidebar from a template
- Strange widget behavior
- WordPress Widgets no drop down
- WordPress RSS widget and Yahoo Pipes
- twenty eleven single.php
- Jetpack ‘Blog Subscription’ widget doesn’t add emails to
- Full Width Container Colour Problems
- How to make custom dashboard widget to display alert in front-end?
- how to enable full width page template in woo theme memorable?
- Can’t remove a widget from admin
- Add a twitter feed to my WordPress website
- Using AJAX in a Widget to Sort items [closed]
- How to create a dashboard to show current user analytics in buddypress
- Widgets not updating despite cache clearing