PHP – WordPress – Filter Category

The given PHP example filter out a category from your WordPress. 
Add this code to your functions.php file.

Code Example:
<?php 
# The Number 312 is my category ID number. Please replace this with your own! 
# Add this code to your functions.php file.

function exclude_cat($query) {
	if ( $query->is_home) {
		$query-> set('cat','-312');
	}
	return $query;
}

add_filter('pre_get_posts','exclude_cat');
?>

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *