title: How to activate an inactive tab woocommerce category products without click
body: <p>Currently, the store is made to display products in certain tabs. This is the code I have in loop-start.php</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  /**
   * Product Loop Start
   *
   * This template can be overridden by copying it to yourtheme/woocommerce/loop/loop-start.php.
   *
   * HOWEVER, on occasion WooCommerce will need to update template files and you
   * (the theme developer) will need to copy the new files to your theme to
   * maintain compatibility. We try to do this as little as possible, but it does
   * happen. When this occurs the version of the template file will be bumped and
   * the readme will list any important changes.
   *
   * @see         https://docs.woocommerce.com/document/template-structure/
   * @package     WooCommerce\Templates
   * @version     3.3.0
   */
  
  if ( ! defined( 'ABSPATH' ) ) {
      exit;
  }
  ?&gt;
  
    &lt;section class="deals-wrapper product-list"&gt;
      &lt;div class="container"&gt;
        &lt;ul class="nav nav-tabs row justify-content-between" id="dealsTab" role="tablist"&gt;
          &lt;?php
                      $i = 0;
  
                      $categories = get_terms( array(
                      'taxonomy'   =&gt; 'product_cat'
                      ) );
  
                      foreach ( $categories as $key =&gt; $category ) {
                              $catname = $category-&gt;name; 
                              $metaterms = get_term_meta($category-&gt;term_id);
                              $thumbnail_id = get_woocommerce_term_meta($category-&gt;term_id, 'thumbnail_id', true );
                              $image = wp_get_attachment_url( $thumbnail_id );
                          
                              //$terms = get_the_terms( $category-&gt;ID, 'product_cat' )
                          
                              $display_category_on_shop_page = get_field('display_category_on_shop_page',$category);
                              if($display_category_on_shop_page == "Yes"){
                          
                  ?&gt;
            &lt;li class="nav-item col-lg-2 col" role="presentation"&gt;
              &lt;a class="nav-link &lt;?php if($i == 0){ $i++; ?&gt; active &lt;?php } ?&gt;" id="&lt;?php echo $category-&gt;slug ?&gt;-tab" data-toggle="tab" href="#&lt;?php echo $category-&gt;slug ?&gt;" role="tab" aria-controls="&lt;?php echo $category-&gt;slug ?&gt;" aria-selected="true"&gt;
                          &lt;img src="&lt;?php echo $image; ?&gt;" alt="apple" /&gt;
                          &lt;span&gt;&lt;?php echo $catname; ?&gt;&lt;/span&gt;
                      &lt;/a&gt;
            &lt;/li&gt;
            &lt;?php  } } wp_reset_postdata(); ?&gt;
        &lt;/ul&gt;
        &lt;div class="tab-content" id="dealsTabContent"&gt;
          &lt;?php 
                      $i = 0;             
                      foreach($categories as $key =&gt; $category) {     
                  ?&gt;
          &lt;div class="tab-pane fade &lt;?php if($i == 0){ $i++; ?&gt; show active &lt;?php } ?&gt;" id="&lt;?php echo $category-&gt;slug ?&gt;" role="tabpanel" aria-labelledby="&lt;?php echo $category-&gt;slug ?&gt;-tab"&gt;
            &lt;div class="deal-tiles" id="accordionExample&lt;?php echo $category-&gt;slug ?&gt;"&gt;
              &lt;?php
                          $c = 1;
                          $count = 1;
                          $args = array(
                              'post_type'      =&gt; 'product',
                              'posts_per_page' =&gt; 20,
                              'product_cat'    =&gt; $category-&gt;slug,
                              'orderby'        =&gt; 'meta_value_num',
                              'order'          =&gt; 'ASC',
                              'meta_key'       =&gt; '_price', 
                              'post_status' =&gt; 'publish'
                          );
                          $loop = new WP_Query( $args );
                          
                          if( $loop-&gt;have_posts()) : 
                          while ( $loop-&gt;have_posts()) : 
                          $loop-&gt;the_post(); 
                          
                          $p_id = wc_get_product()-&gt;get_id();
                          $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
                          $currency = get_woocommerce_currency_symbol();
                          $name = get_the_title();
                          $link = get_the_permalink();
                          
                          $product = wc_get_product(get_the_ID());
                          $thePrice = $product-&gt;get_price();
                          
                          ?&gt;
                &lt;div class="deal-wrapper"&gt;
                  &lt;div class="deal-tile"&gt;
                    &lt;div class="text-center deal-head"&gt;
                      &lt;h5&gt;
                        &lt;?php echo get_the_title(); ?&gt;
                      &lt;/h5&gt;
                    &lt;/div&gt;
                    &lt;div class="deal-body"&gt;
                      &lt;div class="deal-img row"&gt;
                        &lt;div class="deal-phone-img"&gt;
                          &lt;a href="&lt;?php echo $link; ?&gt;" class="product-items"&gt;
                                              &lt;img src="&lt;?php echo $image[0]; ?&gt;" class="img-fluid" alt="phone" /&gt;
                                              &lt;/a&gt;
                        &lt;/div&gt;
                        &lt;div class="deal-phone-details"&gt;
                          &lt;div class="deal-part1"&gt;
                            &lt;h3&gt;
                              &lt;?php echo get_field('phone_detail_gb_data',$p_id); ?&gt;
                            &lt;/h3&gt;
                            &lt;?php 
                                                  while(have_rows('phone_detail_unlimited_data',$p_id)) : the_row();
                                                      $text = get_sub_field('text');
                                                  ?&gt;
                            &lt;p&gt;
                              &lt;?php echo $text; ?&gt;
                            &lt;/p&gt;
                            &lt;?php endwhile;  wp_reset_postdata(); ?&gt;
                          &lt;/div&gt;
                          &lt;div class="deal-part2 d-flex justify-content-between"&gt;
                            &lt;div class="deal-part2-details"&gt;
                              &lt;?php
                                                      if($product-&gt;get_type() == "simple"){
                                                      ?&gt;
  
                                &lt;h5&gt;
                                  &lt;?php echo get_field('network_price_text',$p_id); ?&gt;
                                  &lt;?php echo $currency;  echo $product-&gt;regular_price; ?&gt;pm&lt;/h5&gt;
                                &lt;h5 class="our-price"&gt;
                                  &lt;?php echo get_field('our_price_text',$p_id); ?&gt; :
                                  &lt;?php echo $currency; echo $product-&gt;sale_price; ?&gt;pm&lt;/h5&gt;
                                &lt;h6&gt;
                                  &lt;?php echo get_field('upfront_cost',$p_id); ?&gt;
                                  &lt;?php echo get_field('upfront_cost_text',$p_id); ?&gt;
                                &lt;/h6&gt;
                                &lt;?php
                                                      }else{
                                                      $product_variations = $product-&gt;get_available_variations();
                                                      $variation_product_id = $product_variations [0]['variation_id'];
                                                      $variation_product = new WC_Product_Variation( $variation_product_id );
                                                          $variation_min_price = $product-&gt;get_variation_price();
                                                          $price_regular_min = $product-&gt;get_variation_regular_price();
                                                          $price_sale_min = $product-&gt;get_variation_sale_price();
                                                      
                                                          ?&gt;
                                  &lt;h5 class="network-price"&gt;
                                    &lt;?php echo get_field('network_price_text',$p_id); ?&gt;
                                    &lt;?php echo $currency;  echo $price_regular_min; ?&gt;pm&lt;/h5&gt;
                                  &lt;h5 class="our-price"&gt;
                                    &lt;?php echo get_field('our_price_text',$p_id); ?&gt; :
                                    &lt;?php echo $currency; echo $price_sale_min; ?&gt;pm&lt;/h5&gt;
  
                                  &lt;!--                                                    &lt;?php if ( $price_html = $product-&gt;get_price_html() ) : ?&gt;
                                                          &lt;span class="price"&gt;&lt;?php echo $price_html; ?&gt;&lt;/span&gt;
                                                      &lt;?php endif; ?&gt; --&gt;
  
                                  &lt;h6&gt;
                                    &lt;?php echo get_field('upfront_cost',$p_id); ?&gt;
                                    &lt;?php echo get_field('upfront_cost_text',$p_id); ?&gt;
                                  &lt;/h6&gt;
                                  &lt;?php
                                                      }
                                                      ?&gt;
                            &lt;/div&gt;
                            &lt;div class="deal-part2-img"&gt;
                              &lt;img src="&lt;?php echo get_field('ee_image',$p_id)[" url "]; ?&gt;" alt=""&gt;
                            &lt;/div&gt;
                          &lt;/div&gt;
                        &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="deal-footer"&gt;
                        &lt;div class="row deal-img justify-content-around"&gt;
                          &lt;a href="&lt;?php echo $link; ?&gt;" class="buy-now"&gt;buy now&lt;/a&gt;
                          &lt;a href="&lt;?php echo $link; ?&gt;#detail-section-2" data-Id="detail-section-2" class="buy-now view-detail"&gt;view detail&lt;/a&gt;
                          &lt;!--                                            &lt;div id="heading&lt;?php echo $count; ?&gt;"&gt;
                                                  &lt;h5 class="mb-0 lern-more-btn collapsed" data-toggle="collapse" data-target="#collapse&lt;?php echo $count; ?&gt;" aria-expanded="false" aria-controls="collapse&lt;?php echo $count; ?&gt;"&gt;
                                                      &lt;span&gt;&lt;?php echo get_field('learn_more_text',$p_id); ?&gt;&lt;/span&gt;
                                                      &lt;span&gt;&lt;?php echo get_field('minimise_text',$p_id); ?&gt;&lt;/span&gt;
                                                  &lt;/h5&gt;
                                              &lt;/div&gt; --&gt;
                        &lt;/div&gt;
                        &lt;div id="collapse&lt;?php echo $count; ?&gt;" class="collapse multi-collapse deal-desc"&gt;
                          &lt;ul class="card-body"&gt;
                            &lt;?php 
                                                  while(have_rows('product_details',$p_id)) : the_row();
                                                      $text = get_sub_field('text');
                                                  ?&gt;
                            &lt;li&gt;
                              &lt;p&gt;
                                &lt;?php echo $text; ?&gt;
                              &lt;/p&gt;
                            &lt;/li&gt;
                            &lt;?php endwhile;  wp_reset_postdata(); ?&gt;
                          &lt;/ul&gt;
                          &lt;div class="features-wrapper"&gt;
                            &lt;?php $product_other_detail = get_field('product_other_detail',$p_id); ?&gt;
                            &lt;span class="features-ttl"&gt;&lt;?php echo $product_other_detail["heading"]; ?&gt;&lt;/span&gt;
                            &lt;ul class="features-desc"&gt;
                              &lt;?php 
                                                      while(have_rows('product_other_detail',$p_id)) : the_row();
                                                          while(have_rows('other_details',$p_id)) : the_row();
                                                              $text = get_sub_field('text');
                                                      ?&gt;
                              &lt;li&gt;
                                &lt;?php echo $text; ?&gt;
                              &lt;/li&gt;
                              &lt;?php endwhile; endwhile;  wp_reset_postdata(); ?&gt;
                            &lt;/ul&gt;
                          &lt;/div&gt;
                        &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="compare-btn"&gt;
                        &lt;input type="checkbox" id="compare&lt;?php echo $count; ?&gt;" class="chkbox" data-name="&lt;?php echo htmlspecialchars($name, ENT_QUOTES, 'UTF-8'); ?&gt;" data-price="&lt;?php echo $currency; echo $thePrice; ?&gt;pm" data-image="&lt;?php echo $image[0]; ?&gt;" /&gt;
                        &lt;label class="mb-0 ml-1" for="compare&lt;?php echo $count; ?&gt;"&gt;Compare&lt;/label&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
                &lt;?php $count++; endwhile; endif; ?&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;?php   } wp_reset_postdata(); ?&gt;
        &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>Each time the store is opened from the link, the first tab is active and the content of the first product category is displayed. My goal is to rework the code so that I can activate each category (tab) with a direct link. I want to use the direct link to this category to activate the tab for the respective category and show the products. At the moment I have to click on the tab to get this effect, otherwise the first tab is always active.
  I ask for your help.
  Тhanks.</p>