我创建了一个简单的简码来显示标题和左侧的图标。不知何故,将插入一个封闭的(孤立的)
标记来呈现简码。
function tiemme_title_with_icon ( $atts, $content = null ) {
extract( shortcode_atts( array(
'ico' => '',
'text' => 'title',
), $atts ) );
ob_start();
printf('<div class="title_with_icon"><span class="detail_title ico-%s">%s</span></div>', $ico, $text);
if($content) {
echo '<div class="serv_content"><div class="detail__text pad-icon-indent">';
echo do_shortcode($content);
echo '</div></div>';
}
return ob_get_clean();
}
代码返回以下结果
<div class="title_with_icon">
<span class="detail_title ico-puntivendita">TITLE</span>
</div>
<div class="serv_content">
<div class="detail__text pad-icon-indent">
</p> <!-- this P tag is the one to remove! -->
<p>REAL AND GOOD CONTENT</p>
</div>
</div>