WordPress:Template Tags/previous post link

来自站长百科
跳转至: 导航、​ 搜索

描述[ ]

这个模板标签用在一篇单一的文章permalink网页上,显示一个链接,链接到前一篇文章,前一篇文章指的是在发表时间在当前文章之前。

必须在The Loop内使用这个标签。

用法[ ]

%%% <?php previous_post_link('format', 'link', in_same_cat, 'excluded_categories'); ?> %%%

用法[ ]

默认用法[ ]

用左angular quote («),紧跟着前篇文章的文章标题(按文章日期的时间顺序排列的前一篇文章),显示链接。默认情况下,这个标签像previous_post()一样运行。

[[WordPress:#Examples|« 前一篇文章标题]]
<?php previous_post_link(); ?>

粗体的文章标题作为链接[ ]

显示链接,将时间上较前的文章标题包裹在'strong'标签中(通常将文本设置为粗体的)。

%%% <?php previous_post_link('%link'); ?> %%%

文本作为链接,没有文章标题,没有相同的类别[ ]

显示自定义的文本作为链接,链接到与当前文章同类别的前一篇文章。不包含文章标题。"类别中的前一篇"是自定义文本,可以根据的你的需要更改。

%%% <?php previous_post_link('%link', 'Previous in category', TRUE); ?> %%%

在同一个类别中,一个类别除外[ ]

显示链接,链接到同一个类别中的前一篇文章,只要这篇文章不属于类别13(类别ID#)。你可以将数字改为任何你想要排除的类别。使用" and "作为分隔符可以删除多个类别。

%%% <?php previous_post_link('%link', '类别中的前一篇', TRUE, '13'); ?> %%%

参数[ ]

format
(string) 链接的格式字符串。这个字符串控制了链接前后可以出现什么。字符串中的'%link'会被称为'链接'的任何内容所取代(请看看下一个链接)。'进入%链接'会产生"进入 <a href=..."在这儿放上HTML标签,设计最后的结果。默认为'&laquo; %link'
link
(string) 显示的链接文本。默认为前一篇文章的标题('%title')。
in_same_cat
(boolean) 显示前一篇文章是否必须与当前的文章在同一个类别中。如果设置为正确的,只有来自当前类别的文章才会得到显示。选项是:
  • TRUE
  • FALSE (Default)
excluded_categories
(string) 前一篇文章不应该列出的类别ID。用分开多个类别;例如:'1 和 5 和 15'。没有默认设置。

相关的[ ]

也看看next_post_link()

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,