Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created January 15, 2012 20:16
Show Gist options
  • Save billerickson/1617049 to your computer and use it in GitHub Desktop.
Save billerickson/1617049 to your computer and use it in GitHub Desktop.
Display Posts Shortcode - Exclude Categories
<?php
/**
* Display Posts Shortcode - Exclude Categories
* @author Bill Erickson
* @link http://wordpress.org/extend/plugins/display-posts-shortcode/
*
* @param array $args
* @param array $atts
* @return array $args
*/
function be_display_posts_shortcode_exclude_categories( $args, $atts ) {
if( isset( $atts['not_category'] ) ) {
$cats = explode( ',', $atts['not_category'] );
$args['category__not_in'] = $cats;
}
return $args;
}
add_filter( 'display_posts_shortcode_args', 'be_display_posts_shortcode_exclude_categories', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment