类别页面中的Woocommerce简短描述出错

时间:2016-11-08 13:58:51

标签: php wordpress woocommerce

这是我正在使用的代码,它似乎在登录时正常工作

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>";
    }
}

当我退出并检查页面时,每个类别中的第一个产品都没有显示我添加的简短描述,尽管它在我登录时出现。

代码有问题吗?

1 个答案:

答案 0 :(得分:0)

应该如何:http://imgur.com/LNYDygg

退出时的外观:http://imgur.com/XlMnV83