This is what I need to do:
This is what I've done and tried so far:
archive-product.php
in my child theme.custom-shop-class
just before the product loop start, because I want to target the looped products specifically.page-id-4
because if I hover over the "shop" page in wp-admin, it gave me http://.../post.php?post=4&action=edit
The problem I'm having is as follows:
archive-product.php
template is being used in the other various shop pages and not only in the main "shop" page (correct me if I'm wrong), so when I target my custom-shop-class
with CSS, it affects all the other shop pages using the same template file, and it must not.page-id-??
class in the body tag (as in the usual WP pages).Any suggestions on the best method/solution?
Thanks in advance, Mario.
Navigate to Appearance > Customize in your WordPress dashboard. Scroll down and click “additional CSS” in the menu. You will find a text field to add your CSS codes.
To do this, go to Appearance → Customize → WooCommerce → Product Catalog. Change the 'Shop page display' option to 'Show categories & products'. This will list all your categories in a grid layout at the top of the WooCommerce shop page, with a product table listing the products underneath.
Set a conditional statement to check for the primary shop page, then echo the div in question if that statement evaluates to true.
WooCommerce Conditional Tag for 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With