Skip to content

Instantly share code, notes, and snippets.

@10h30
Forked from srikat/functions.php
Created July 17, 2015 03:57
Show Gist options
  • Save 10h30/69a3f7c84552e102d8cf to your computer and use it in GitHub Desktop.
Save 10h30/69a3f7c84552e102d8cf to your computer and use it in GitHub Desktop.
Excluding categories when using Display Posts Shortcode. http://sridharkatakam.com/exclude-categories-using-display-posts-shortcode/
//* 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;
}
[display-posts cat_not_in="30"]
[display-posts cat_not_in="30, 43"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment