1
関連商品リストの短い説明の制限を設定する必要があります。関連商品リストの簡略説明の制限を設定してください
私は、フィルタを使用して、製品一覧ページのためにこれを行っている:
function my_filter_woocommerce_short_description($post_excerpt) {
if(is_product()){
}else{
$post_excerpt = get_the_content();
$post_excerpt = preg_replace(" (\[.*?\])",'',$post_excerpt);
$post_excerpt = strip_shortcodes($post_excerpt);
$post_excerpt = strip_tags($post_excerpt);
$post_excerpt = substr($post_excerpt, 0, 265);
$post_excerpt = substr($post_excerpt, 0, strripos($post_excerpt, " "));
$post_excerpt = trim(preg_replace('/\s+/', ' ', $post_excerpt));
$post_excerpt = $post_excerpt.'... <a href="'.get_permalink($product_id).'">more</a>';
//$post_excerpt=substr($post_excerpt , 0 ,265);
return $post_excerpt.'...';
}
}
add_filter('woocommerce_short_description','my_filter_woocommerce_short_description',10, 2);
を私はこのフィルタの内側に、製品ページに完全な短い説明を表示する必要があるが、私はif is製品を作成しました。 問題は製品ページ内です。製品リストページに表示されているので、私は短く表示する必要がある関連製品のリストもあります。
どうすればいいですか?
は、あなたの代わりに使用したフィルタの
「をthe_excerpt」を追加しかし、問題は、私は、製品ページに抜粋を行う必要があるということですが、それに
関連商品リストのみ –
これは難しいことではありません。あなたが言ったように、関連する製品リストに簡単な説明を表示するには、上記の関数に 'the_excerpt' –