我有一个创建列的快捷代码,编辑器(文本视图)中的页面如下所示;
[two-column]<ul>
<li>Annual statutory accounts preparation</li>
<li>Independent Examination service</li>
<li>Audit file preparation</li>
<li>Gift Aid returns</li>
<li>Payroll</li>
</ul>[/two-column]
[two-column]<ul>
<li>Bookkeeping service</li>
<li>Management accounts</li>
<li>Charity Commission administration service</li>
<li>OSCR administration service</li>
<li>Companies House administration service</li>
</ul>[/two-column]
不幸的是,当它出现在页面上时,它是这样的;
<p><div class="two-column">
<ul>
<li>Annual statutory accounts preparation</li>
<li>Independent Examination service</li>
<li>Audit file preparation</li>
<li>Gift Aid returns</li>
<li>Payroll</li>
</ul>
<p></div><br />
<div class="two-column">
<ul>
<li>Bookkeeping service</li>
<li>Management accounts</li>
<li>Charity Commission administration service</li>
<li>OSCR administration service</li>
<li>Companies House administration service</li>
</ul>
<p></div></p>
</div>
现在我不想删除所有
<p>
标记(通过操纵wpautop),那么如何处理此短代码。
短代码;
function column_shortcode($atts = [], $content = null)
{
$content = \'<div class="two-column">\'.$content.\'</div>\';
return $content;
}
add_shortcode(\'two-column\', \'column_shortcode\');
SO网友:Chris Pink
好吧,似乎有人走了这条路,事实上。。。。shortcode_unautop()
工作完成。它在编辑器中看起来很优雅,在输出中起作用。
现在的短代码如下所示;
function column_shortcode($atts = [], $content = null)
{
$content = \'<div class="two-column">\'.$content.\'</div>\';
$content = shortcode_unautop($content);
return $content;
}
add_shortcode(\'two-column\', \'column_shortcode\');