【问题标题】:How to add excerpt in woocommerce for product title while displaying products in a page or category loop [closed]如何在 woocommerce 中为产品标题添加摘录,同时在页面或类别循环中显示产品 [关闭]
【发布时间】:2018-03-06 07:55:00
【问题描述】:

面临页面中显示的产品列表的问题 http://bubblz.in/test-2/ 第一行中的产品名称将影响第二行中的产品。 任何人都知道如何解决这个问题,否则任何关于添加产品名称长度摘录的想法?

【问题讨论】:

  • 有什么影响?
  • 错字我刚刚更正了,看看你可能知道问题的链接

标签: wordpress woocommerce customization hook-woocommerce


【解决方案1】:

在functions.php中添加这段代码

add_filter('the_title', 'single_product_page_title', 10, 2);

function single_product_page_title($title, $id) {
    if(is_product_category() || is_page() ) {                
        $title = mb_strimwidth($title, 0, 15, '...');
        return $title;
    }

    return $title;
}

【讨论】:

  • 感谢您的想法,请您看看这个网站oyehappy.com/surprises/premium/birthday,在第二行搜索这样的产品“Cabana, Candles and Cu...”。跨度>
  • 我在我的子主题functions.php中更新了你的代码,但仍然面临同样的问题bubblz.in/test-2检查第三行第一个产品。(为你的参考添加了测试产品标题)
  • 是的,过滤器正在单个产品显示页面上工作 如何为类别循环页面分配相同的内容。 bubblz.in/test-2
  • 是的,显示特定类别的所有产品的页面,我已经更新了上面的代码,仍然是第 3 行第 1 个产品,它不能正常工作。
  • 为了测试自己添加了 5
猜你喜欢
  • 1970-01-01
  • 2018-12-10
  • 2017-10-14
  • 1970-01-01
  • 2018-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-02
相关资源
最近更新 更多