dongyongmin5711 2019-02-15 03:57 采纳率: 100%
浏览 191
已采纳

在WooCommerce产品标题中附加文本字符串

<div class="woocommerce-loop-product__title"><? wc_get_template('single-product/title.php');?>

Im trying to make this string say: "Product Name More Info"

I can get the Product Name part fine, but how do i concatenate the 'more info' to this code to make it output correctly? Every echo attempt i try breaks my site

  • 写回答

2条回答 默认 最新

  • dongyong6332 2019-02-15 04:30
    关注

    If you look to the template single-product/title.php code you have essentially just this:

    the_title( '<h1 class="product_title entry-title">', '</h1>' );
    

    The WordPress function the_title() echoes the product title, so you can't use echo again if you want to append "More Info" to the title. You will use this line instead:

    <div class="woocommerce-loop-product__title"><? the_title( '<h1 class="product_title entry-title">', ' More Info</h1>' ); ?>
    

    or in a more cleaner way.

    <div class="woocommerce-loop-product__title"><? the_title( '<h1 class="product_title entry-title">', ' '. __("More Info") . '</h1>' ); ?>
    

    Tested and works.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口