Remove a category from the front-page.php

The correct way to do this is to make use of pre_get_posts which change the query vars just before the main query is executed.

Here is an example from the codex to exclude categories from the home page/blog page. For a full list of available parameters and values that you can use with pre_get_posts, visit the WP_Query codex page:

function exclude_category( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
        $query->set( 'cat', '-1,-1347' );
add_action( 'pre_get_posts', 'exclude_category' );


Tags: , ,

No comments yet.

Leave a Reply