Изменить ссылку "подробнее" на странице одного продукта WooCommerce / сайте Wordpress - PullRequest
1 голос
/ 06 мая 2020

Я пытаюсь понять, где хранятся различные файлы шаблонов для WooCommerce, Wordpress и темы, которую я использую (Reykjavi c).

Я успешно создал дочернюю тему для внести изменения и успешно найти и отредактировать некоторые файлы шаблонов.

Я бы хотел, чтобы ссылка была частью самого текста, а не отдельным абзацем. Шаблоны отображают его на странице следующим образом:

enter image description here

<div class="woocommerce-product-details__short-description">
 <p>The B&amp;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&amp;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 ); но не знаете, где это устанавливается?

Может ли кто-нибудь указать мне правильное направление?

1 Ответ

1 голос
/ 06 мая 2020
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>';
}

Попробуйте этот фрагмент кода

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...