模板标签 the_content() 显示当前文章的内容。该标签必须在 WordPress 主循环(loop)中,该标签必须在 WordPress 主循环(loop)中。若文章使用快速标签 来截取摘要,the_content()标签将只在非单篇文章或非固定链接文章上显示前的摘要部分。the_content()标签可包含一个规定内容和样式的参数,该参数会生成“继续阅读全文”的链接。
- 关于 <span id="more-1093"></span> 标签有以下三条规定:
- <!--more-->快速标签中的more前不得有空格。否则 <!--more-->将无法发挥作用。
- <!--more-->快速标签无法在模板中运行(会被模板忽略),如single.php只会显示一篇文章。
用法:
- <?php the_content( $more_link_text, $strip_teaser, $more_file ); ?>
使用以下方式在“More”中加入标题,在the_title()标签和display参数的帮助下,若文章使用 ,该示例可以显示”Continue reading ACTUAL POST TITLE”(继续阅读当前文章标题)。
- <?php the_content("Continue reading " . the_title('', '', false)); ?>
如果the_content()不能按计划运行(如当你希望显示 标签前的内容,the_content()却显示了全文内容),你可以用全局变量$more改写这一行为:
- <?php
- global $more; // Declare global $more (before the loop).
- $more = 0; // Set (inside the loop) to display content above the more tag.
- the_content("More...");
- ?>
你可以用get_the_content函数返回文章内容的值,而非直接输出文章内容。示例如下:
- <?php $content = get_the_content(); ?>
请注意!get_the_content 无法进行以下操作,因此你最好手动添加以下代码,直到核心程序升级成功:
- <?php
- $content = apply_filters('the_content', $content);
- $content = str_replace(']]>', ']]>', $content);
- ?>
the_content()位于wp-includes/post-template.php