-
-
Save billerickson/95e2650214136fc0a707 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Exclude Category from Blog | |
* | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/customize-the-wordpress-query/ | |
* @param object $query data | |
* | |
*/ | |
function be_exclude_category_from_blog( $query ) { | |
if( $query->is_main_query() && $query->is_post_type_archive( 'events' ) && !is_admin() ) { | |
$query->set( 'category__not_in', array( 12, 34, 47 ) ); | |
} | |
} | |
add_action( 'pre_get_posts', 'be_exclude_category_from_blog' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment