Function Reference/next post

来自WordPress中文文档
跳转至: 导航搜索

wordpress.org.cn


includeonlydiv style=clear:both; background-color:#FFFFFF; border:1px solid #FFFFFF; color:#c00; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists. See also onlyincludecodewp-includes/deprecated.php/code/onlyinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Template Description

Link to the source code on http://core.trac.wordpress.org/browser/.

Parameters

  1. filename
  2. (option) path to codetag/code (version) or codetrunk/code. This option is only used for a new function.br /Default: codetrunk/code -- trunk is the latest bleeding edge development version of WordPress.

Usage

Link to the stable version: pre检查到模板循环:模板:Trac/pre

Link to trunk: pre检查到模板循环:模板:Trac/pre

/div

wordpress.org.cn./div/includeonlynoinclude

Description

This Template is used by Codex:Template Messages.

Usage

pre 检查到模板循环:模板:Message /pre

Result

检查到模板循环:模板:Message

/noinclude


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 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.

div style=border:1px solid blue; width:50%; padding:10pxnext post: Next Post Title/div

?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 raquo; is the specified text in this example; you can put whatever you want.

div style=border:1px solid blue; width:50%; padding:10pxNext raquo;/div

%%% ?php next_post('%','Next raquo;', '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.

div style=border:1px solid blue; width:50%; padding:10pxPrevious: Previous Post Titlenbsp;nbsp;nbsp;nbsp;|nbsp;nbsp;nbsp;nbsp;Next: Next Post Title/div

lt;pgt;?php previous_post('%', 'Previous:', 'no'); ? 
| ?php next_post('%', 'Next:', 'no'); ?lt;/pgt;

Using Arrows Not Text

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

div style=border:1px solid blue; width:50%; padding:10pxlaquo; laquo; Previous Post Titlenbsp;nbsp;nbsp;nbsp;|nbsp;nbsp;nbsp;nbsp;Next Post Title raquo; raquo; /div

pre?php previous_post('amp;laquo; amp;laquo; %', , 'yes'); ? | ?php next_post('% amp;raquo; amp;raquo; ', , 'yes'); ?/pre

Parameters

format 
(string) Format string for the link. tt'%'/tt in string will be replaced with the link, so tt'Go to %'/tt will generate Go to a href=... Defaults to tt'%'/tt.
next 
(string) Link text to display. Defaults to tt'next post: '/tt.
title 
(string) Indicates whether title should be used as link text. If set to tt'yes'/tt, immediately follows next (above). Options are:
  • tt'yes'/tt (Default)
  • tt'no'/tt
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:
  • tt'yes'/tt
  • tt'no'/tt (Default)
limitnext 
(integer) Sets next post link on numeric value of parameter (current post ID plus limitnext). Defaults to tt1/tt. 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 'ttand/tt': tt'1 and 5 and 15'/tt. There is no default. Parameter works with versions of WordPress 1.5.2 and above.

Related

See also previous_post().

body_class, next_image_link, next_post_link, next_posts_link, post_class, post_password_required, posts_nav_link, previous_image_link, previous_post_link, previous_posts_link, single_post_title, sticky_class, the_category, the_category_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss, the_ID, the_meta, the_shortlink, the_tags, the_title, the_title_attribute, the_title_rss, wp_link_pages

includeonlydiv style=clear:both; background-color:#F7F7F7; border:1px solid #CCCCCC; color:#000000; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;See also index of Function Reference and index of Template Tags./div/includeonlynoinclude

Description

This Template is used by Codex:Template Messages.

Usage

pre 检查到模板循环:模板:Message /pre

Result

检查到模板循环:模板:Message

/noinclude