A
A
Anonimmus2021-04-29 14:19:39
WordPress
Anonimmus, 2021-04-29 14:19:39

How does terms() work in woo??

Hello, tell me please. How it works?? Got a list of categories, got a link to these categories.
By clicking on the link, I go to the page "conditional-site" / product-category / "category name" however the page is empty .... which wokomers file should I edit?? Or what archive page are you talking about?? please tell me...

activated the storefront theme and there is a blank page

<?php $term = get_queried_object(); ?>
<?php
    $terms = get_terms(array(
      'taxonomy' => 'product_cat',
      'hide_empty' => true,
      'exclude' => '',
      'pad_counts'=> true,
      'parent' => 0
    ));
if($terms){ ?>
          <div class="ItemsWrap owl-carousel">
            <?php foreach($terms as $k => $term){ ?>
              <?php $category_thumbnail = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true); ?>
              <a href="<?=get_term_link($term->term_id);?>" class="ItemBox">
                <span class="Image">
                  <?php $image = wp_get_attachment_image_src($category_thumbnail, 'woo_preview_item'); if($image[0]){ ?>
                    <img src="<?=$image[0];?>" alt="<?=$term->name;?>" alt="asd">
                  <?php }else{ ?>
                    <img src="<?=wp_get_attachment_image_url('799', 'woo_preview_item');?>" alt="<?=$category->name;?>">
                  <?php } ?>
                </span>
                <span class="NameBox">
                  <span class="Name"><?=$term->name;?></span>
                  <span class="Icon icon-plus"></span>
                </span>
              </a>
            <?php } ?>
          </div>
<?php } ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Zolin, 2021-04-29
@artzolin

Just remove the arguments you don't understand and it will work.

$terms = get_terms(array(
  'taxonomy' => 'product_cat',
  'hide_empty' => false,
));

608b0b953facb334465116.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question