[contact-form-7 id="24078" title="Feedback EN"]

Featured templates

WordPress. How to exclude category from displaying on Blog page

This tutorial is going to show you how to exclude category from displaying on Blog page in WordPress.

WordPress. How to exclude category from displaying on Blog page

If you want to exclude category from displaying on Blog page, perform the following steps:

  1. Go to your WordPress admin panel, navigate to Appearance -> Editor:

    how to exclude category from displaying.1

  2. Look for custom-function.php file of your theme##### and open it to edit.

  3. Add this piece of php code to the file mentioned above and save changes:

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

    how to exclude category from displaying.2

Feel free to check the detailed video tutorial below:

WordPress. How to exclude category from displaying on Blog page