You can do this with pre_get_posts
.
This hook is called after the query variable object is created, but before the actual query is run.
For excluding category id 32
and 39
from homepage, you can setup a function like this.
function wpse_exclude_categories( $query ) {
if ( is_admin() )
return;
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '-32,-39' );
}
}
add_action( 'pre_get_posts', 'wpse_exclude_categories', 1 );
EDIT
Although I would strongly recommend you to use WP_Query
. But you can change your code to exclude category posts with query_posts
.
$args = array(
'cat' => '-32,-33',
'paged' => $paged
);