0
商品説明の長さを制限します。「おすすめ商品」または「最近の商品」の商品説明の長さを制限する
function short_product_titles_chars($title, $id) {
if (
(is_shop() || is_product_tag() || is_product_category()) &&
get_post_type($id) === 'product')
{
if (strlen($title) >= 25) {
return substr($title, 0, 25) . '...';
} else {
return $title;
}
} else {
return $title;
}
}
add_filter('the_title', 'short_product_titles_chars', 10, 2);
そして、このコードはショップページに正常に動作しますが、私は「おすすめの製品」や「最近の製品」ウィジェットオム私のスタートページを使用する場合、それは動作しません。 ウィジェットでも動作するようにこのコードを変更するにはどうすればよいですか?
私の英語のために申し訳ありません。
こんにちは、あなたの答えはthxですが、それは私のために働いていません。 –