我想在产品包装盒中显示产品简短说明。我正在使用它,
<?php if ( $description_words_limit > 0 ) { ?>
<div class="atgrid__item__description">
<?php echo adventure_tours_get_short_description( $item->post ); ?>
</div>
<?php } ?>
功能:
if ( ! function_exists( 'adventure_tours_get_short_description' ) ) {
/**
* Returns short description for current post or for the specefied post.
*
* @param WP_Post $forPost optional post object (if empty - current post will be used).
* @param int $word_limit max allowed words count.
* @return string
*/
function adventure_tours_get_short_description( $forPost = null, $word_limit = null ) {
$resetPost = ! empty( $forPost );
if ( null === $forPost ) {
$forPost = get_post();
}
if ( ! $forPost ) {
return '';
}
$text = $forPost->post_excerpt ? $forPost->post_excerpt : $forPost->post_content;
if ( $text ) {
return adventure_tours_do_excerpt( $text, $word_limit );
} else {
return $text;
}
}
}
此代码打印简短描述文本,但我想要完整的HTML。 我怎样才能做到这一点?
感谢您的帮助