[英]Edit 'more details' link on WooCommerce single Product Page / Wordpress site
我试图弄清楚 WooCommerce、Wordpress 和我正在使用的主题(雷克雅维克)的各种模板文件的存储位置。
我已经成功创建了一个子主题来进行修改,并成功找到并编辑了一些模板文件。
我想将链接移动为文本本身的一部分,而不是单独的段落。 模板在页面上显示如下:
<div class="woocommerce-product-details__short-description">
<p>The B&G Zeus3 Glass Helm 19 is designed specifically for blue water sailing, multihulls and superyachts; this premium, super-fast, super large-screen, multifunction display sits at the heart of your fully integrated navigation system and comes with B&G’s unique sailing features including SailSteer and RacePanel.</p>
<p class="product-description-link-container">
<a href="#tab-description" class="product-description-link">More details…</a>
</p>
我找到了这个 WooCommerce 模板文件,我相信它会将简短描述发送到页面:
/**
* Single product short description
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/short-description.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
global $post;
$short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );
if ( ! $short_description ) {
return;
}
?>
<div class="woocommerce-product-details__short-description">
<?php echo $short_description; // WPCS: XSS ok. ?>
</div>
</div>
我相信我需要找到或修改发生这种情况的帖子摘录。 apply_filters( 'woocommerce_short_description', $post->post_excerpt );
但不确定这是在哪里设置的?
谁能指出我正确的方向?
add_action( 'woocommerce_short_description', 'modify_short_description' );
function modify_short_description( $short ) {
return $short . '<a rel="nofollow" href="https://www.google.com" class="read_more">More details</a>';
}
试试这个代码片段
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.