<p>标记跳过第一段

用户名

我有以下代码将我的Wordpress内容分为2列(Bootstrap 3框架)。它将内容拆分为“更多”标签。

functions.php

function split_content() {
global $more;
$more = true;
$content = preg_split('/<span id="more-\d+"><\/span>/i', get_the_content('more'));
// first content section in column1
$ret = '<div id="column1" class="col-md-6">'. array_shift($content). '</div>';
// remaining content sections in column2
if (!empty($content)) $ret .= '<div id="column2" class="col-md-6"><p>'. implode($content). '</p></div>';
return apply_filters('the_content', $ret);
}

这将所有内容放在<p>标记等中,除了第一段。所有的过滤器/ etc似乎都不会影响第一列的第一段,但是对于其他所有内容都可以正常工作

m4n0

您需要用以下代码替换第六行。如您所见,第一段是由第六行生成的,因此缺少p标签。在代码的注释部分中也提到了它。

$ret = '<div id="column1" class="col-md-6"><p>'. array_shift($content). '</p></div>';

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章