If this tutorial is not what you were looking for, you still have any questions, suggestions or concerns - feel free to let us know. Please help us to serve you better!

Your Name

Your Email

Your Message (required)


Featured templates

WordPress. How to exclude a category from displaying on Blog page

This tutorial will show you how to exclude posts assigned to specific category from displaying on Blog page in WordPress.

WordPress. How to exclude category from displaying on Blog page

  1. Log into your WordPress dashboard, and navigate to Appearance > Editor:


  2. Choose themeXXXXX, where XXXXX is your actual theme number in Select theme to edit drop down:


  3. Find custom-function.php file and open to edit it.


  4. You will need to get your category ID before editing this file. You should navigate to Posts > Categories:


  5. Hover over the category name (that you want to exclude from blog page) to see its ID:


  6. Add this code to the very end of the file before closing php tag ?> and replace 6 with your category ID:

    function exclude_category( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
    $query->set( 'cat', '-6' );
    add_action( 'pre_get_posts', 'exclude_category' );
  7. Click Update file button to save changes.

  8. If you want to exclude 2 or more categories, you should separate them with comma in the code, example:

    $query->set( 'cat', '-6,-7' );
  9. Refresh your Blog page, now it doesn’t display posts from the category that was excluded in the file.

Feel free to check the detailed video tutorial below:

WordPress. How to exclude category from displaying on Blog page

  • Larry G. Maguire

    Thanks for this tutorial Kate. Although simple, I’ve been trying to get this sorted for a while and your article gave me what I needed.

    No votes yet.
    Please wait...
Live Chat
We help you to choose the right product.
Start chat