• Does not work filter pre_get_posts, so categories, that are excluded from search are displaing in live search, but if search button was clicked, it show “NO reasults”. How to fix it?

    function wcs_exclude_category_search( $query ) {
      if ( is_admin() || ! $query->is_main_query() )
        return;
    
      if ( $query->is_search ) {
        $query->set( 'cat', '-3' );
      }
    
    }
    add_action( 'pre_get_posts', 'wcs_exclude_category_search', 1 );
    • This topic was modified 6 years, 4 months ago by max143.
  • The topic ‘Excluded categories from search’ is closed to new replies.