wordpress - Woocommerce targeting the shop page only with css -
this need do:
- to target only main shop page css (a specific custom class created mentioned below).
this i've done , tried far:
- i have override template of
archive-product.php
in child theme. - in override template i've added div custom class
custom-shop-class
before product loop start, because want target looped products specifically. - i tried targeting class
page-id-4
because if hover on "shop" page in wp-admin, gave mehttp://.../post.php?post=4&action=edit
the problem i'm having follows:
- from i've discovered same
archive-product.php
template being used in other various shop pages , not in main "shop" page (correct me if i'm wrong), when targetcustom-shop-class
css, affects other shop pages using same template file, , must not. - there no unique identifier or class shop page,
page-id-??
class in body tag (as in usual wp pages).
any suggestions on best method/solution?
thanks in advance, mario.
set conditional statement check primary shop page, echo div in question if statement evaluates true.
woocommerce conditional tag main shop page:
is_shop()
example
if (is_shop()) { echo "<div class='custom-shop-class'></div>"; } else { echo "<div class='custom-product-category-class'></div>"; }
alternatively:
<?php if (is_shop()):?> <div class="custom-shop-class"></div> <?php else: ?> <div class="custom-product-category-class"></div> <?php endif;?>