我有一个名为'list-two'的自定义元框(使用Advanced Custom Fields),我想在编辑窗格中使用'more'标签将文本/内容分成两部分列。这是到目前为止我的代码,但只做什么,我需要它的一半做:将内容拆分为两列 - Wordpress
在我functions.php文件:
function split_morecontent() {
global $morecontent;
$morecontent = true;
$copy = preg_split('/<span id="more-\d+"><\/span>/i', get_field('list_two'));
for($c = 0, $csize = count($copy); $c < $csize; $c++) {
$copy[$c] = apply_filters('list_two', $copy[$c]);
}
return $copy;
}
在我的帖子模板文件:
<?php
// split text into array
$copy = split_morecontent();
// output first content section in column1
echo '<section class="split">', array_shift($copy), '</section>';
// output remaining content sections in column2
echo '<section class="split">', implode($copy), '</section>';
?>
输出运行时注意以下HTML(注意其实际上并未将内容拆分为两个标签):
<section class="split">
<ul class="footnote">
<li>Christopher Gray</li>
<li>Jean Jullien<!--more--></li>
<li>Nous Vous</li>
<li>Liv Bargman</li>
<li>Luke Drozd</li>
</ul>
</section>
<section class="split">
<!-- the last 3 <li> tags from the list above should be displayed within here.-->
</section>
是的,这就是我试图编辑的代码。基本上来自Sitepoint的代码只会分割the_content。我试图调整它以拆分另一个所见即所得的内容框(我称之为list_two),但无法使其正常工作。所以我需要SitePoint的代码在后期编辑页面上使用额外的所见即所得编辑器。任何想法我可能会这样做? – egr103