【问题标题】:Add product short description between title and price lines在标题和价格行之间添加产品简短描述
【发布时间】:2017-02-14 07:40:48
【问题描述】:

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

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

谢谢。

【问题讨论】:

  • 这是您自己的代码吗?我不确定 $output 最后会发生什么,但如果它只是被淘汰,你很可能只需要添加类似 $output .= "
    your description here ...
    " 之类的东西;在这段代码的第二行之后

标签: php html wordpress woocommerce product


【解决方案1】:

您应该使用专用的 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>';

这应该可以工作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-08
    • 1970-01-01
    • 2021-07-12
    • 2018-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多