Hide any Category or Asides from Main Content of k2 theme

k2 theme provides inbuilt option for selecting your asides category and displaying posts from it using K2 sidebar manager. But recently, k2 does not exclude posts from asides in main content pages. That means apart from displaying asides posts in sidebar, it keeps on displaying them on homepage too!

This mean duplicate content on both sidebar and main page which looks bad. There is a easier way to do this. And this method works not only for removing posts from asides category but any category you want. To achieve this put the following code at bottom of functions.php just before ?> tag.


function ignore_asides ($query) {
    if ($query->is_home)
        $query->set('cat', '-x');
    return $query;

add_filter('pre_get_posts', 'ignore_asides');

where x refers to any category you want to exclude posts from.