在标题和价格行之间添加产品简短描述


Add product short description between title and price lines

如何在这段代码中在标题之后和价格之前添加简短描述:

$output .= '<div class="desc">';
                            $output .= '<h4><a href="'. get_the_permalink() .'">'. get_the_title() .'</a></h4>';
if ( $price_html = $product->get_price_html() ) $output .= '<span class="price">'. $price_html .'</span>';
                        $output .= '</div>';

谢谢。

您应该使用专用的WordPress get_the_excerpt() 函数:

$output .= '<div class="desc">
    <h4><a href="'. get_the_permalink() .'">'. get_the_title() .'</a></h4>
    <p>'. get_the_excerpt() .'</p>';
if ( $price_html = $product->get_price_html() ) $output .= '<span class="price">'. $price_html .'</span>';
                        $output .= '</div>';
                    $output .= '</div>';

应该可以