mhds
mhds

Reputation: 67

Add product short description between title and price lines

How can I add short description in this code after title and before price:

$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>';

Thanks.

Upvotes: 3

Views: 441

Answers (1)

LoicTheAztec
LoicTheAztec

Reputation: 254220

You should use the dedicated WordPress get_the_excerpt() function:

$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>';

This should work

Upvotes: 2

Related Questions