Can’t hide post in wordpress

I want to exclude a category from homepage. I tried the below code, it’s working for my site in local server but after I moved the code to production server it won’t work at all.

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

I even tried to install ‘wp-hide-post’ plugin, yet, it’s not working.

Read More

What am I missing?

Related posts