我正在使用警报器模板。在主页中。php此代码用于显示公文包内容
print_excerpt(200);
但我只需要在之前显示内容<!--more-->
我用过这个:
the_content( $more_link_text, FALSE);
但它不起作用。它显示所有内容我正在使用警报器模板。在主页中。php此代码用于显示公文包内容
print_excerpt(200);
但我只需要在之前显示内容<!--more-->
我用过这个:
the_content( $more_link_text, FALSE);
但它不起作用。它显示所有内容您可以使用WordPress功能get_extended
获取字符串的不同部分(前一部分和后一部分<!--more-->
标签)。get_extended
返回一个包含三个键的数组,其中main
和extended
重要的是:$arr[\'main\']
包含更多标记之前的零件,以及$arr[\'extended\']
more标记后面的部分。
这将产生如下结果:
// Fetch post content
$content = get_post_field( \'post_content\', get_the_ID() );
// Get content parts
$content_parts = get_extended( $content );
// Output part before <!--more--> tag
echo $content_parts[\'main\'];
不幸的是,WordPress中的所有函数似乎都应该呈现摘录(get_extended
, get_extended
) 不要应用HTML标记,也不要将段落中的回车转换为aspected。
如果需要使用格式呈现摘录,我建议您使用以下代码:
global $more;
$more_backup = $more;
$more = 0;
the_content(\'\');
$more = $more_backup;
通过这项工作,您可以告诉\\u content()函数它在一个循环中,在more标记之前获取内容。