WordPress: Template Tags/the excerpt:修订间差异
(新页面: == Description == Displays the excerpt of the current post with [...] at the end, which is not a "read more" link. If you do not provide an explicit excerpt to a post (in the post edito...) |
|||
(未显示2个用户的10个中间版本) | |||
第1行: | 第1行: | ||
== | == 描述 == | ||
显示当前文章的摘录,结尾有[...],[...]并不是一个"阅读更多"链接。如果你没有提供一篇清晰明了的文章摘录(在文章编辑器的可选择的摘录区),标签会显示[[WordPress:Glossary#Excerpt|teaser]],指的是文章内容的前55个字。同时在后一种情况下,[[WordPress:Glossary#HTML|HTML]]标签和图形都从摘录内容中清除了。必须在[[WordPress:The Loop|The Loop]]内使用这个标签。 | |||
== | == 用法 == | ||
%%% <?php the_excerpt(); ?> %%% | %%% <?php the_excerpt(); ?> %%% | ||
== | ==例子 == | ||
=== 默认用法 === | |||
显示文章摘录。将非单一/非permalink的文章用在一个代替品,替换[[WordPress:Template_Tags/the_content|the_content()]],迫使摘录在Loop内显示。 | |||
<?php the_excerpt(); ?> | |||
=== 与条件式标签一起使用 === | |||
在归档网页(由 <tt>is_archive()</tt>测试)或者在类别网页(<tt>is_category()</tt>)上时,将the_content()标签替换为the_excerpt()。 | |||
下面的两个例子在1.5版本以及更高的版本中都能够运行。 | |||
%%% <?php if(is_category() || is_archive()) { | %%% <?php if(is_category() || is_archive()) { | ||
第27行: | 第29行: | ||
} ?> %%% | } ?> %%% | ||
对于WordPress1.5之前的版本,只有下面的能够运行: | |||
%%% <?php if($cat || $m) { | %%% <?php if($cat || $m) { | ||
第35行: | 第37行: | ||
} ?> %%% | } ?> %%% | ||
== | == 参数 == | ||
这个标签没有参数。 | |||
== | == 比较 the_excerpt() 和 the_content() == | ||
有时候只使用[[WordPress:Template_Tags/the_content|the_content()]]函数,更有意义。[[WordPress:Template_Tags/the_content|the_content()]]根据是否使用了 | |||
%%%<!--More-->%%%标签,来决定显示什么。 | |||
%%%<!--More-->%%% | %%%<!--More-->%%%标签将文章/网页分成了两个部分:只有标签之前的内容可以显示在列表上。 | ||
记住,当只显示文章/网页(单一的)的时候,(当然)忽视了%%%<!--More-->%%%。 | |||
== | == 相关的== | ||
{{ | {{标签文章标签}} | ||
{{ | {{没有Param标签页底文字}} |
2008年7月18日 (五) 09:37的最新版本
描述[ ]
显示当前文章的摘录,结尾有[...],[...]并不是一个"阅读更多"链接。如果你没有提供一篇清晰明了的文章摘录(在文章编辑器的可选择的摘录区),标签会显示teaser,指的是文章内容的前55个字。同时在后一种情况下,HTML标签和图形都从摘录内容中清除了。必须在The Loop内使用这个标签。
用法[ ]
%%% <?php the_excerpt(); ?> %%%
例子[ ]
默认用法[ ]
显示文章摘录。将非单一/非permalink的文章用在一个代替品,替换the_content(),迫使摘录在Loop内显示。
<?php the_excerpt(); ?>
与条件式标签一起使用[ ]
在归档网页(由 is_archive()测试)或者在类别网页(is_category())上时,将the_content()标签替换为the_excerpt()。
下面的两个例子在1.5版本以及更高的版本中都能够运行。
%%% <?php if(is_category() || is_archive()) {
the_excerpt(); } else { the_content(); } ?> %%%
对于WordPress1.5之前的版本,只有下面的能够运行:
%%% <?php if($cat || $m) {
the_excerpt(); } else { the_content(); } ?> %%%
参数[ ]
这个标签没有参数。
比较 the_excerpt() 和 the_content()[ ]
有时候只使用the_content()函数,更有意义。the_content()根据是否使用了 %%%%%%标签,来决定显示什么。
%%%%%%标签将文章/网页分成了两个部分:只有标签之前的内容可以显示在列表上。
记住,当只显示文章/网页(单一的)的时候,(当然)忽视了%%%%%%。
相关的[ ]
the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss, previous_post_link, next_post_link, posts_nav_link, the_meta,