I'd like to know, Is there any ways to remove certain category posts from the blog page.

Actually, I own a technology blog and I'd like to implement free software directory or marketplace in my blog within download category. But The download category post will not display in the blog page and only accessible from download category. I have heard about some plugin but I trust codes instead of the plugin.

Thanks in Advance :)


1 Answer 1


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' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.