这是我使用的代码,它似乎在登录
时正常工作add_action('woocommerce_after_shop_loop_item_title', 'lk_woocommerce_product_excerpt', 35, 2);
if (!function_exists('lk_woocommerce_product_excerpt')) {
function lk_woocommerce_product_excerpt()
{
$content_length = 10;
global $post;
$content = $post->brief_description;
$wordarray = explode(' ', $content, $content_length + 1);
if (count($wordarray) > $content_length) :
array_pop($wordarray);
array_push($wordarray, '...');
$content = implode(' ', $wordarray);
$content = force_balance_tags($content);
endif;
echo "<span class='excerpt'><p>$content</p></span>";
}
}
当我注销并检查页面时,每个类别中的第一个产品不显示我添加的简短描述,尽管它在我登录时出现。
代码有问题吗?
应该怎么做:https://i.stack.imgur.com/cdwP8.jpg
注销时的样子:https://i.stack.imgur.com/KasgW.jpg