• Resolved aehernandez

    (@aehernandez)


    Hi!

    I’m trying to exclude a few categories from the blog page. I’m using the following snippet on my child theme’s functions.php:

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

    After updating my blog page, the blog only shows the posts that are part of those category IDs instead of excluding them.

    Could you please help me with this? Thank you in advance!

    • This topic was modified 4 years, 6 months ago by t-p. Reason: Moved to Fixing WordPress from Developing with WordPress
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude category’ is closed to new replies.