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 me http://.../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 target custom-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;?> 

conditional tags | woothemes documentation


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo