Title: Shortcode not working in Text Widget
Last modified: August 21, 2016

---

# Shortcode not working in Text Widget

 *  [Lionbunny](https://wordpress.org/support/users/lionbunny/)
 * (@lionbunny)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/)
 * I’m trying to use the text widget to display only the most recent ‘news’ and ‘
   blog’ posts instead of all recent posts.
 * I’ve added
    `add_filter('widget_text', 'do_shortcode');` to the functions.php
   through the editor and `[display-posts category="blog,news" posts_per_page="5"]`
   to the widget itself but it still displays the shortcode as text instead of executing
   it. I haven’t found any other solutions beyond adding the filter to functions.
   php

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

 *  [Evan Herman](https://wordpress.org/support/users/eherman24/)
 * (@eherman24)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742350)
 * You added it to functions.php of your theme? I would confirm its in your theme
   functions.php and not a seperate, inactive theme or inside of a plugin file.
 * If you can, it’d be best to do so via FTP and not through the dashboard editor.
 *  Thread Starter [Lionbunny](https://wordpress.org/support/users/lionbunny/)
 * (@lionbunny)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742352)
 * ok I replied too early, let me double check
 *  Thread Starter [Lionbunny](https://wordpress.org/support/users/lionbunny/)
 * (@lionbunny)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742360)
 * Yep.
 * Went into wp-content > themes> current theme> functions.php and made sure the
   filter was there. Also added it to the functions.php files of the rest of the
   themes I have, just to see… still not displaying the shortcode :/
 *  [Evan Herman](https://wordpress.org/support/users/eherman24/)
 * (@eherman24)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742364)
 * hmm, that’s interesting. I know out of the box WordPress doesn’t support short
   codes in widgets (which your aware of), and it should work after adding in that
   filter.
 * Maybe try adding a priority to the filter?
 *     ```
       add_filter( 'widget_text', 'do_shortcode', 11)
       ```
   
 * If that doesn’t work are you able to switch over to the default theme (2012,2013
   or 2014) and trying it again with the filter in the function folder.
 * I would also attempt to see if its a plugin conflict by deactivating all plugins.
 * Evan
 *  Thread Starter [Lionbunny](https://wordpress.org/support/users/lionbunny/)
 * (@lionbunny)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742393)
 * priority on the filter did not work, deactivating plugins did not work, and switching
   themes did not work.
 * I am completely stumped.
 *  [Evan Herman](https://wordpress.org/support/users/eherman24/)
 * (@eherman24)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742398)
 * Wow, so am I. That’s very interesting. Right out of the box, adding that filter
   to your functions, things should definitely work.
 * After switching themes, did you re-enter the filter for the shortcode in text
   widgets? The functions.php is theme specific and won’t follow when you switch
   themes.
 *  Thread Starter [Lionbunny](https://wordpress.org/support/users/lionbunny/)
 * (@lionbunny)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742423)
 * Yep. I added the filter to every theme’s functions.php
 * Weird that it’s just not working across the board…
 *  [Fryvisuals](https://wordpress.org/support/users/fryvisuals/)
 * (@fryvisuals)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742818)
 * Having the same issue. Found a bunch of posts on this but adding the filter does
   nothing which is bizarre.
 *  Thread Starter [Lionbunny](https://wordpress.org/support/users/lionbunny/)
 * (@lionbunny)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742819)
 * Hey Fry, start a new thread with your specific info… they always say to do that
   I’m guessing because everyone’s site/setup is different and what works for one
   person might not work for another. Maybe there’s a new fix or workaround or someone
   else might know the solution!
 *  Thread Starter [Lionbunny](https://wordpress.org/support/users/lionbunny/)
 * (@lionbunny)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742820)
 * Also, and I have no idea how, the recent posts widget just started working for
   my site one day… I run a twentytwelve child theme so I guess the problem worked
   itself out in one of the updates.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742821)
 * [@fryvisuals](https://wordpress.org/support/users/fryvisuals/)
 * please be aware that not all code in square brackets is real shortcode –
 * please post in your own topic what code exactly are you trying to use, and which
   plugin are you using.
 *  [paross](https://wordpress.org/support/users/paross/)
 * (@paross)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742824)
 * See: [http://andornagy.com/enable-scripts-and-shortcodes-in-wordpress-text-widgets/](http://andornagy.com/enable-scripts-and-shortcodes-in-wordpress-text-widgets/)

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

The topic ‘Shortcode not working in Text Widget’ is closed to new replies.

## Tags

 * [post categories](https://wordpress.org/support/topic-tag/post-categories/)
 * [text widget](https://wordpress.org/support/topic-tag/text-widget/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 12 replies
 * 5 participants
 * Last reply from: [paross](https://wordpress.org/support/users/paross/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/shortcode-not-working-in-text-widget/#post-4742824)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
