Answer the question
In order to leave comments, you need to log in
How to separate subcategory template and product template?
I need to create a custom subcategory and product output. Those. when you click on a category, a template opens with subcategories, without products. Clicking on a subcategory opens the products of that subcategory. Now I have products displayed in the subcategory. How to remove them? Is this all done in archive-product.php?
Now I have the following code:
This is where subcategories are displayed and the_content is displaying products and descriptions of subcategories. But I don't think it's quite right. How to do it right?
<?php get_header(); ?>
<main role="main">
<section class="section_content_top">
<div class="box">
<div class="top_box">
<h1 class="title_h1"><?php the_title(); ?></h1>
</div>
</div>
</section>
<section class="single_content">
<div class="box">
<div class="woocommerce_breadcrumb">
<?php echo woocommerce_breadcrumb(); ?>
</div>
<?php
$parentid = get_queried_object_id();
$args = array(
'parent' => $parentid
);
$terms = get_terms( 'product_cat', $args );
if ( $terms ) {
echo '<div class="row">';
foreach ($terms as $term) {
?>
<div class="col-3">
<div class="module_catalog">
<a href="<?php echo esc_url(get_term_link($term)) ?>" class="image"
id="<?php echo $term->term_id ?>">
<?php
$image = get_field('product-category-extra-image', $term);
$thumbnail_id = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true);
$icon = wp_get_attachment_url($thumbnail_id); ?>
<img src="<?php echo $image['url']; ?>" alt="">
</a>
<div class="content_box">
<div class="icon">
<img src="<?php echo $icon; ?>" alt="">
</div>
<h3 class="title_h3"><a
href="<?php echo esc_url(get_term_link($term)) ?>"><?php echo $term->name; ?></a>
</h3>
</div>
</div>
</div>
<?php
}
echo ' </div>';
}
?>
<div class="wrap_content">
<?php the_content(); ?>
</div>
</div>
</section>
</main>
<?php get_footer(); ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question