February 4, 2014 by Sridhar Katakam
Then to exclude a single category for example, use this shortcode on a post or page:
[display-posts cat_not_in="30"]
view raw
gistfile1.txt hosted with ❤ by GitHub
to exclude multiple categories, use this sample shortcode:
[display-posts cat_not_in="30, 43"]
References:
https://wordpress.org/plugins/display-posts-shortcode/
http://wordpress.org/support/topic/plugin-display-posts-shortcode-how-do-you-exclude-a-category-from-the-posts?replies=5#post-2918793
http://www.billerickson.net/code/display-posts-shortcode-exclude-posts/
http://wordpress.org/support/topic/shortcode-32
Bill Erickson’s Display Posts Shortcode plugin can be used to easily display a list of posts wherever shortcodes work. It does not have a built-in option to specify the IDs or slugs of categories if you wish to exclude any. But it can be extended using the display_posts_shortcode_args filter.
Add the code below in child theme’s functions.php to make available a cat_not_in parameter whose value will be the ID or comma separated IDs of categories you wish to be excluded from the listing:
//* Display Posts Shortcode - Exclude Categories
add_filter( 'display_posts_shortcode_args', 'be_display_posts_shortcode_exclude_categories', 10, 2 );
function be_display_posts_shortcode_exclude_categories( $args, $atts ) {
if( isset( $atts['cat_not_in'] ) ) {
$categories = explode( ',', $atts['cat_not_in'] );
$args['category__not_in'] = $categories;
}
return $args;
}