0

As you know, we can assign a "Category" to any post we write. We can also use a "Category" as link on the menu. Good!

By default, WordPress will display all your posts in all the categories on your front page.

However, how to prevent Wordpress displaying a "Category" type on the front page? Example, I have a post with a category name "Football". I don't want all posts with this category to be displayed on the front page, how to do that? I will access it only on the menu.

Thank

2
1

You can use pre_get_posts

Exclude categories on your main 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' );
0

Try the Ultimate Category Excluder plugin, it does what you ask to not show on the front page, plus has options to exclude from your RSS Feed, searches, or as an archive.

https://wordpress.org/plugins/ultimate-category-excluder/

A different approach might be to not use recent posts on your front page, but make a static Page your front view as a welcome to the site. You can use something like Display Posts plugin to put posts from categories you want on the front or in a footer/sidebar https://wordpress.org/plugins/display-posts-shortcode/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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