【问题标题】:Woocommerce do not show product description on catalog page but still show in single product pagesWoocommerce 不在目录页面上显示产品描述,但仍显示在单个产品页面中
【发布时间】:2016-09-18 20:14:11
【问题描述】:

目录页面中的产品描述和长度不等的简短描述过于混乱。这使每种产品的设置不同,我希望每种产品在目录网格中占用更多更少相同的空间。因此,我想从目录页面中删除产品的描述,并仅在用户选择产品时将其显示在单个产品页面中。如果可能的话,我还希望搜索功能不包含产品简短描述中的文本。任何建议将不胜感激。

【问题讨论】:

  • 默认主题还是这样吗?因为显示摘录的woocommerce_template_single_excerpt() 不会被 WooCommerce 的 content-product.php 模板调用,该模板是存档循环中默认显示的模板。意思是,它可以由您的主题添加。
  • 嗨,是的,据我所知这是默认设置,但是我正在运行各种插件和子主题模板 (Templatemela)。我已经在所有选项中寻找了几个小时,我可以非常自信地说,不允许从目录页面中删除描述。但是,我找到了一种解决方法,我从一个类似的问题中得到了从单个产品页面中删除简短细节的想法。编辑 css 文件:wp-content -> 主题 -> myTheme -> css -> woocommerce.css。添加以下代码: .product-block-inner > div[itemprop="description"] { display: none; }
  • 不,我的意思是像二十一十六这样的默认主题,因为据我从 WooCommerce 得知,摘录不应该在那里。这是Twenty Sixteen screenshot 我建议查看您主题的content-product.php 模板和/或搜索您的主题以查看woocommerce_template_single_excerpt 是否被添加到某个地方的挂钩中。
  • 啊,不,我使用的是名为 Digita 的他们。感谢您的帮助,我在 content-product.php 中找不到 woocommerce_template_single_excerpt 但我找到的修复程序现在可以解决。
  • 那么大概woocommerce_template_single_excerpt 被添加到了一个钩子中。但 CSS 将在紧要关头发挥作用。

标签: php html css woocommerce product


【解决方案1】:
function filter_woocommerce_short_description( $post_post_excerpt ) { 
if(is_shop() || is_product_category() ) {
    return false;
} else {
    return $post_post_excerpt; 
}    
};  
// add the filter 
add_filter( 'woocommerce_short_description', 'filter_woocommerce_short_description', 10, 1 ); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-17
    • 1970-01-01
    • 2017-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多