Display Posts Shortcode
[resolved] How do you exclude a category from the posts? (5 posts)

  1. cinderalla
    Posted 4 years ago #

    Is it possible to exclude a category? I've tried the following with no success:

    [display-posts category="-testing"]
    [display-posts category="-2"]


  2. cinderalla
    Posted 4 years ago #

    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 );
  3. lanee1014
    Posted 4 years ago #

    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?

  4. jendinsho
    Posted 4 years ago #

    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

  5. Bill Erickson
    Plugin Author

    Posted 4 years ago #

    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/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Display Posts Shortcode
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic