Exclude Some Category from WP blog

function exclude_category($query) {
if ( $query->is_home() ) {
$query->set('cat', '-xx');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');

Or add below line before start loop have_posts() ) : while ( have_posts()

<?php $query = new WP_Query( 'cat=-3,-8' ); ?>

Leave a Reply

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