Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Excluding categories when 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
You can’t perform that action at this time.