Title: Shortcode in a shortcode in a widget
Last modified: August 20, 2016

---

# Shortcode in a shortcode in a widget

 *  [Christopher Martin](https://wordpress.org/support/users/christopher-martin/)
 * (@christopher-martin)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-a-shortcode-in-a-widget/)
 * I need to put a shortcode in a shortcode in a widget. To be exact I need this
   in a widget:
 * [wpv-view name=”Bookmaker – Payment Type List View” sapymttype =”[types field
   =”deposit-withdrawal”][/types]”]
 * However the shortcode inside the shortcode is not shown properly, and this is
   shown at the end where the shortcode is being incorrectly truncated: [/types]”]
 * This works in the main content, but in the widget it doesn’t.
 * I added this to funtions.php to originally make the shortcode work in the widget:
 * add_filter( ‘widget_text’, ‘do_shortcode’);
 * Many thanks for any help…

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-a-shortcode-in-a-widget/#post-2949469)
 * What widget?
 *  Thread Starter [Christopher Martin](https://wordpress.org/support/users/christopher-martin/)
 * (@christopher-martin)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-a-shortcode-in-a-widget/#post-2949472)
 * just a normal text widget…
 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-a-shortcode-in-a-widget/#post-2949488)
 * You could try changing the priority on your `add_filter`, something like `add_filter('
   widget_text', 'do_shortcode', 1);`. Maybe that will work, but you may have a 
   fundamental conflict with the widget code itself. If so, you will need to create
   your own widget.
 *  Thread Starter [Christopher Martin](https://wordpress.org/support/users/christopher-martin/)
 * (@christopher-martin)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-a-shortcode-in-a-widget/#post-2949537)
 * Thanks… I tried that, then I realised that if I remove add_filter( ‘widget_text’,‘
   do_shortcode’); from functions file completely the shortcode still works exactly
   the same!
 * Unfortunately I only know enough to be dangerous, so I am not sure where to look
   next to try and get this working!
 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-a-shortcode-in-a-widget/#post-2949544)
 * Copy the text widget shortcode from wp-includes/default-widgets.php. It is a 
   PHP class named ‘WP_Widget_Text’. The whole declaration is ‘class WP_Widget_Text
   extends WP_Widget’. Copy the whole thing to your theme’s functions.php and give
   it a new name by changing the ‘WP_Widget_Text’ part only, so that you have, for
   example, ‘class My_Custom_Text_Widget extends WP_Widget’. Now edit the ‘widget’
   function inside that class. Just before `$text = apply_filters...` you want to
   put `$text = do_shortcode($text);` Now put `register_widget('My_Custom_Text_Widget');`
   underneath the whole ‘My_Custom_Text_Widget’ class. That is, after the closing‘}’
   of that that class.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Shortcode in a shortcode in a widget’ is closed to new replies.

## Tags

 * [do_shortcode](https://wordpress.org/support/topic-tag/do_shortcode/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)
 * [widget](https://wordpress.org/support/topic-tag/widget/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-a-shortcode-in-a-widget/#post-2949544)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
