- alkkdlkx
13 分钟 25 秒之前 - tmhvrb
13 分钟 36 秒之前 - vvqfyciu
13 分钟 37 秒之前 - detqjlm
13 分钟 40 秒之前 - bjebss
13 分钟 44 秒之前 - nlkepn
13 分钟 49 秒之前 - cwuuwc
13 分钟 49 秒之前 - kntqia
13 分钟 49 秒之前 - 自动的功能还是少用~
2 小时 2 分钟之前 - 自动的功能还是少用~
2 小时 3 分钟之前
该标签显示当前文章的内容。该标签必须在WordPress主循环(loop)。
若文章使用快速标签 <!--more--> 来截取摘要,the_content()标签将只在非单篇文章或非固定链接文章上显示 <!--more-->前的摘要部分。the_content()标签可包含一个规定 <!--more-->内容和样式的参数,该参数会生成“继续阅读全文”的链接。
关于 <!--more-->:
<?php the_content( $more_link_text, $strip_teaser, $more_file ); ?>
$more_link_text
(字符串)(可选)“more”链接的链接文本
默认值: '(more...)'
$strip_teaser
(布尔型)(可选)显示(FALSE)或隐藏(TRUE)more链接前的文本。
默认值:FALSE
$more_file
(字符串)(可选)more链接所指向的文件
默认值:当前文件
设计“More”文本
文章使用<!--more--> 快速标签时,显示文章内容并用"Read more..." 代替<!--more--> 后的内容。
<?php the_content('Read more...'); ?>
在“More”中加入标题
该示例类似于上一个示例,但在the_title()标签和display参数的帮助下,若文章使用 <!--more-->,该示例可以显示"Continue reading ACTUAL POST TITLE"(继续阅读当前文章标题)
<?php the_content("Continue reading " . the_title('', '', false)); ?> 改写存档/单个页面
如果the_content()不能按计划运行(如当你希望显示<!--more--> 标签前的内容,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...");
?>
如果需要显示所有正文:
<?php
global $more; // Declare global $more (before the loop).
$more = 1; // Set (inside the loop) to display all content, including text below more.
the_content();
?>
你可以用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
发表新评论