在 WooCommerce 单个产品页面/Wordpress 网站上编辑 'more details' link
Edit 'more details' link on WooCommerce single Product Page / Wordpress site
我想了解为 WooCommerce、Wordpress 和我正在使用的主题 (Reykjavic) 存储各种模板文件的位置。
我已经成功地创建了一个子主题来进行我的修改,并成功地找到并编辑了一些模板文件。
我想将 link 移动到文本本身的一部分,而不是一个单独的段落。模板在页面上显示如下:
<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>
我认为我需要找到或修改发生这种情况的 post 摘录。 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>';
}
试试这个代码片段
我想了解为 WooCommerce、Wordpress 和我正在使用的主题 (Reykjavic) 存储各种模板文件的位置。
我已经成功地创建了一个子主题来进行我的修改,并成功地找到并编辑了一些模板文件。
我想将 link 移动到文本本身的一部分,而不是一个单独的段落。模板在页面上显示如下:
<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>
我认为我需要找到或修改发生这种情况的 post 摘录。 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>';
}
试试这个代码片段