我有一個名爲'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