Title: [Plugin: Display Posts Shortcode] How do you exclude a category from the posts?
Last modified: August 20, 2016

---

# [Plugin: Display Posts Shortcode] How do you exclude a category from the posts?

 *  Resolved [cinderalla](https://wordpress.org/support/users/cinderalla/)
 * (@cinderalla)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-how-do-you-exclude-a-category-from-the-posts/)
 * Is it possible to exclude a category? I’ve tried the following with no success:
 *  [display-posts category=”-testing”]
    [display-posts category=”-2″]
 * [http://wordpress.org/extend/plugins/display-posts-shortcode/](http://wordpress.org/extend/plugins/display-posts-shortcode/)

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

 *  Thread Starter [cinderalla](https://wordpress.org/support/users/cinderalla/)
 * (@cinderalla)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-how-do-you-exclude-a-category-from-the-posts/#post-2834910)
 * Got it figured out! Used your “display_posts_shortcode_args” filter and modified
   as below (in case anyone else is stuck on this):
 *     ```
       function be_display_posts_shortcode_exclude_posts( $args, $atts ) {
           if( isset( $atts['cat_not_in'] ) ) {
           $cats = explode( ',', $atts['cat_not_in'] );
           $args['category__not_in'] = $cats;
         }
         return $args;
       }
       add_filter( 'display_posts_shortcode_args', 'be_display_posts_shortcode_exclude_posts', 10, 2 );
       ```
   
 *  [lanee1014](https://wordpress.org/support/users/lanee1014/)
 * (@lanee1014)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-how-do-you-exclude-a-category-from-the-posts/#post-2834921)
 * cinderalla could you expound upon this a bit more? The code snippet you offer…
   where is that from? The plugin code?
 * What did you change/modify?
 *  [jendinsho](https://wordpress.org/support/users/jendinsho/)
 * (@jendinsho)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-how-do-you-exclude-a-category-from-the-posts/#post-2834964)
 * use these snippets to make the plugin more dynamic. You ad them to your functions.
   php file in your theme. Is what I’ve read although I haven’t done it yet I don’t
   need to exclude anything as of yet
 *  [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * (@billerickson)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-how-do-you-exclude-a-category-from-the-posts/#post-2835046)
 * Correct, you can either add them to your theme’s functions.php file, or create
   your own “core functionality” plugin that contains all these snippets. The benefit
   to the latter approach is that when you change themes you don’t have to find 
   the snippets and add them to your new theme.
 * More information: [http://www.billerickson.net/core-functionality-plugin/](http://www.billerickson.net/core-functionality-plugin/)

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

The topic ‘[Plugin: Display Posts Shortcode] How do you exclude a category from 
the posts?’ 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/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 4 participants
 * Last reply from: [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-how-do-you-exclude-a-category-from-the-posts/#post-2835046)
 * Status: resolved