Created
December 10, 2011 23:14
-
-
Save davemac/1456987 to your computer and use it in GitHub Desktop.
Function to exclude a category(s) from the main loop (pre WP 3.3) in certain categories
This file contains hidden or 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
add_action( 'pre_get_posts', 'dm_exclude_category_from_category' ); | |
function dm_exclude_category_from_category( $query ) { | |
global $wp_the_query; | |
if( $wp_the_query === $query && $query->is_category( array (4,5,6,7) ) ) { | |
$query->set( 'cat', '-25' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment