我尝试将<!--more-->
标记之前的文章内容与Wordpress中的其他内容分开。
我有两列:
<!--more-->
标记之前的所有内容组成的“子标题”。<!--more-->
标记之前的所有内容。我使用以下代码分隔两个部分: 这是“子标题”
<h2><?php global $more; $more=0; the_content(''); $more=1; ?></h2>
这是本文的其余部分。
<?php the_content( '', true ); ?>
一切正常,但我还剩下两件文物。
<p class="p1">...text...</p>
<p><span id="more-15"></span></p>
如何摆脱文物?我现在真的有想法,他们正在调整我的布局。
谢谢!
答案 0 :(得分:1)
这应该可以让你前进。
<?php
//Output sub-title
global $more;
$more = 0;
$out = apply_filters( 'the_content', get_the_content('') );
$out = str_replace( ']]>', ']]>', $out );
$out = strip_tags( $out, '<br><a><em><u><strong>' ); //may need to add more tags
echo '<h2>'.$out.'</h2>';
$more = 1;
?>
<?php
//Output content
$out = apply_filters( 'the_content', get_the_content('', TRUE ) );
$out = str_replace( ']]>', ']]>', $out );
$repl = '<p><span id="more-' . get_the_ID() . '"></span></p>';
$out = str_replace($repl, '', $out);
echo $out;
?>
更好的方法是将这些作为the_content
的过滤器,但不知道整个网站结构,这可能会引入其他布局错误。