WordPress:Template Tags/next post

来自站长百科
Xxf3325讨论 | 贡献2008年6月27日 (五) 11:19的版本 (新页面: {{Deprecated}} == Description == Used on single post/permalink pages, this tag lists the next post in chronological order from the current post. It can w...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

模板:Deprecated

Description

Used on single post/permalink pages, this tag lists the next post in chronological order from the current post. It can work in conjuntion with the previous_post() tag. This tag must be used in WordPress:The Loop.

For the index, category, and archives templates, use the posts_nav_link() tag.

Replace With

next_post_link().

Usage

%%% <?php next_post('format', 'next', 'title', 'in_same_cat',

               limitnext, excluded_category); ?> %%%

Examples

Default Usage

By default, displays text "next post:" as link along with post title.

[[WordPress:#Examples|next post: Next Post Title]]
<?php next_post(); ?>

Using Text As Link, Without Post Title

Displays specified text as link, without including the post title. If excessively long post titles break your layout, you may want to use this. "Next »" is the specified text in this example; you can put whatever you want.

[[WordPress:#Examples|Next »]]

%%% <?php next_post('%','Next »', 'no'); ?> %%%

Using Specific Text

Displays previous and next post links in the format with the text before the post title not shown as a link.

Previous: [[WordPress:#Examples|Previous Post Title]]    |    Next: [[WordPress:#Examples|Next Post Title]]
<p><?php previous_post('%', 'Previous:', 'no'); ?> 
| <?php next_post('%', 'Next:', 'no'); ?></p>

Using Arrows Not Text

To display text, like arrows («), at the beginning of the previous post link and at the end of the next post link so it looks like:

[[WordPress:#Examples|« « Previous Post Title]]    |    [[WordPress:#Examples|Next Post Title » » ]]
<?php previous_post('&laquo; &laquo; %', '', 'yes'); ?>
| <?php next_post('% &raquo; &raquo; ', '', 'yes'); ?>

Parameters

format
(string) Format string for the link. '%' in string will be replaced with the link, so 'Go to %' will generate "Go to <a href=..." Defaults to '%'.
next
(string) Link text to display. Defaults to 'next post: '.
title
(string) Indicates whether title should be used as link text. If set to 'yes', immediately follows next (above). Options are:
  • 'yes' (Default)
  • 'no'
in_same_cat
(string) Indicates whether the next post link must be in the same category/categories as current. Parameter works with versions of WordPress 1.5.1.3 and above. If post is listed in more than one category, it will show posts within the parent category, not the child category. Options are:
  • 'yes'
  • 'no' (Default)
limitnext
(integer) Sets next post link on numeric value of parameter (current post ID plus limitnext). Defaults to 1. Default is recommended.
excluded_category
(integer -or- string) Numeric category ID(s) from which the next post should not be listed. Separate multiple categories with an 'and': '1 and 5 and 15'. There is no default. Parameter works with versions of WordPress 1.5.2 and above.

Related

See also previous_post().

模板:Tag Post Tags

模板:PHP Function Tag Footer