Woocommerce 仅针对 css 的商店页面

Woocommerce targeting the shop page only with css

这是我需要做的:

这是我到目前为止所做和尝试过的:

我遇到的问题如下:

有什么最好的建议吗method/solution?

提前致谢, 马里奥

设置一个条件语句来检查主要商店页面,如果该语句的计算结果为真,则回显有问题的 div。

主要商店页面的 WooCommerce 条件标签:

is_shop()

例子

if (is_shop()) {
echo "<div class='custom-shop-class'></div>";
} else {
echo "<div class='custom-product-category-class'></div>";
}

或者:

<?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

要以此处提供的答案为基础,我如何进一步根据活动的 WPML 语言向商店页面添加唯一标识符? (我基本上只是尝试减小德语版商店页面上的字体大小 - 事实证明这很难做到)

使用带有 is_shop 条件的过滤器 body_class,您可以定位到主要的 WooCommerce 商店页面。

add_filter( 'body_class', 'woo_shop_class' );
// Add WooCommerce Shop Page CSS Class
function woo_shop_class( $classes ) {
  if ( is_shop() )  // Set conditional
    $classes[] = 'woo-shop'; // Add Class
return $classes;
}

代码在您的主题 functions.php 文件中。