WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] [Plugin: Display Posts Shortcode] How do you exclude a category from the posts?

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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 );

    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?

    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

    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/

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] [Plugin: Display Posts Shortcode] How do you exclude a category from the posts?’ is closed to new replies.
Skip to toolbar