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

---

# Shortcode not working in widget

 *  Resolved [Lightpurple](https://wordpress.org/support/users/pamkaur14/)
 * (@pamkaur14)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/shortcode-not-working-in-widget/)
 * Hi,
 * I love this plugin! Thanks so much for it. I have tried multiple other plugins
   and have not been able to get them to work the way I want.
 * I only have 1 minor issue now and was wondering if you could help me. I have 
   done the following:
 * Added the filter `add_filter( 'widget_text', 'do_shortcode' );` to my functions.
   php file to be able to work the shortcode in a widget.
 * I also have the following in my CSS file for styling:
    .display-posts-listing.
   listing-item {text-transform: uppercase; font-size: 0.5em; display: inline-block;}.
   display-posts-listing img {float: center; margin: 0 20px 5px 0; text-align: center;}
 * I then added the following shortcode to a text widget: `[display-posts tag="featured
   female" post_status="publish" image_size="thumbnail" posts_per_page="3" orderby
   ="rand"]`
 * and it doesn’t seem to be working. I am using the same shortcode on a page and
   it works. I am not sure if it has something to do with the following function
   which I added to my functions.php file as well:
 *     ```
       //----------------------------------------------------------
       // POsts by Tag Shortcode plugin: add H2 to title //----------------------------------------------------------
       add_filter( 'posts_by_tag_shortcode_output', 'format_pbts_title', 10, 7 );
       function format_pbts_title( $output, $atts, $image, $title, $date, $excerpt, $inner_wrapper ) {
       // Make Title and H2
       $title = ' <h2>'. $title .'</h2>';
       // Now let's rebuild the output.
       $output = '<' . $inner_wrapper . ' class="listing-item">' . $image . $title . $date . $excerpt . '</' . $inner_wrapper . '>';
       // Finally we'll return the modified output
       return $output; }
       ```
   
 * I did the above to get the title under the thumbnail. Any help on getting the
   shortcode to work in the widget would be great. Thanks in advance!
 * [https://wordpress.org/plugins/display-posts-shortcode/](https://wordpress.org/plugins/display-posts-shortcode/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Lightpurple](https://wordpress.org/support/users/pamkaur14/)
 * (@pamkaur14)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/shortcode-not-working-in-widget/#post-4887946)
 * Don’t worry about my post above. I have decided to use another plugin for the
   widget posts. Cheers.

Viewing 1 replies (of 1 total)

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

 * ![](https://ps.w.org/display-posts-shortcode/assets/icon-256x256.jpg?rev=2940963)
 * [Display Posts - Easy lists, grids, navigation, and more](https://wordpress.org/plugins/display-posts-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/display-posts-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/display-posts-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/display-posts-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/display-posts-shortcode/reviews/)

## Tags

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

 * 1 reply
 * 1 participant
 * Last reply from: [Lightpurple](https://wordpress.org/support/users/pamkaur14/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/shortcode-not-working-in-widget/#post-4887946)
 * Status: resolved