ちょうどget_the_contentの値を処理するための新しい関数を作成()の単語のみ最大数を取得し、最後に「続きを読む」のリンクを追加します。次に
function custom_single_product_summary(){
$maxWords = 50; // Change this to your preferences
$description = strip_tags(get_the_content()); // Remove HTML to get the plain text
$words = explode(' ', $description);
$trimmedWords = array_slice($words, 0, $maxWords);
$trimmedText = join(' ', $trimmedWords);
if(strlen($trimmedText) < strlen($description)){
$trimmedText .= ' — <a href="' . get_permalink() . '">Read More</a>';
}
echo $trimmedText;
}
元にそれを使用しますあなたが使用しようとしていたオーバーライド・コード:
remove_action('woocommerce_single_product_summary',
'woocommerce_template_single_excerpt', 20);
add_action('woocommerce_single_product_summary', 'custom_single_product_summary', 10);
UPDATED ANSWER: はVALUをエコーするために、アクションフックを変更eを返すのではなく、WooCommerceが出力を印刷することを期待しているからです。
長い説明では製品の詳細を読むことはできません。これは、タブにコンテンツを表示するためのものではありません。 – Yasir