WordPress: Template Tags/previous post:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: {{Deprecated}} == Description == Used on single post/permalink pages, this tag lists the previous post in ''chronological order'' from the current post. ...)
 
无编辑摘要
第1行: 第1行:
{{Deprecated}}
{{Deprecated}}
{{取消的}}
== Description ==
== Description ==
== 描述 ==


Used on single post/[[WordPress:Glossary#Permalink|permalink]] pages, this tag lists the previous post in ''chronological order'' from the current post. It can work in conjuntion with the [[WordPress:Template_Tags/next_post|next_post()]] tag.  This tag must be used in [[WordPress:The Loop]].
Used on single post/[[WordPress:Glossary#Permalink|permalink]] pages, this tag lists the previous post in ''chronological order'' from the current post. It can work in conjuntion with the [[WordPress:Template_Tags/next_post|next_post()]] tag.  This tag must be used in [[WordPress:The Loop]].
这个标签用在一篇单一的文章/[[WordPress:Glossary#Permalink|permalink]]网页上,列出了在当前文章''之前''发表的文章。这个标签可以与[[WordPress:Template_Tags/next_post|next_post()]]标签一起运行。必须在[[WordPress:The Loop|The Loop]]内使用这个标签。


For the index, category, and archives templates, use the [[WordPress:Template_Tags/posts_nav_link|posts_nav_link()]] tag.
For the index, category, and archives templates, use the [[WordPress:Template_Tags/posts_nav_link|posts_nav_link()]] tag.
对于索引,类别,和归档模板,请使用[[WordPress:Template_Tags/posts_nav_link|posts_nav_link()]]标签。


== Replace With ==
== Replace With ==
== 取代==
[[WordPress:Template_Tags/previous_post_link|previous_post_link()]].


[[WordPress:Template_Tags/previous_post_link|previous_post_link()]].
[[WordPress:Template_Tags/previous_post_link|previous_post_link()]].


== Usage ==
== Usage ==
== 用法 ==
%%% <?php previous_post('format', 'previous', 'title', 'in_same_cat',
                    limitprev, excluded_category); ?> %%%


%%% <?php previous_post('format', 'previous', 'title', 'in_same_cat',
%%% <?php previous_post('format', 'previous', 'title', 'in_same_cat',
第16行: 第35行:


== Examples ==
== Examples ==
==例子 ==


===Default Usage===
===Default Usage===
===默认用法===


By default, displays text "previous post:" as link along with post title.
By default, displays text "previous post:" as link along with post title.
默认情况下,显示文本"前一篇文章:"与文章标题一起作为链接。


<div style="border:1px solid blue; width:50%; padding:10px">[[WordPress:#Examples|previous post: Previous Post Title]]</div>
<div style="border:1px solid blue; width:50%; padding:10px">[[WordPress:#Examples|previous post: Previous Post Title]]</div>
   
  <div style="border:1px solid blue; width:50%; padding:10px">[[WordPress:#Examples|前一篇文章: 前一篇文章标题]]</div>
%%% <?php previous_post(); ?> %%%
 
%%% <?php previous_post(); ?> %%%
%%% <?php previous_post(); ?> %%%


===Using Text As Link, Without Post Title===
===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. "&laquo; Previous" is the specified text in this example; you can put whatever you want.
Displays specified text as link, without including the post title. If excessively long post titles break your layout, you may want to use this. "&laquo; Previous" is the specified text in this example; you can put whatever you want.
显示规定的文本作为链接,不包括文章标题。如果过长的文章标题破坏了你的布局,你可能想试试这个。"&laquo; 前一个"是这个例子中规定的文本;你可以剪除任何你想要剪除的内容。


<div style="border:1px solid blue; width:50%; padding:10px">[[WordPress:#Examples|&laquo; Previous]]</div>
<div style="border:1px solid blue; width:50%; padding:10px">[[WordPress:#Examples|&laquo; Previous]]</div>
%%% <?php previous_post('%','&laquo; Previous', 'no'); ?> %%%
<div style="border:1px solid blue; width:50%; padding:10px">[[WordPress:#Examples|&laquo; 前一个]]</div>
   
   
%%% <?php previous_post('%','&laquo; Previous', 'no'); ?> %%%
%%% <?php previous_post('%','&laquo; Previous', 'no'); ?> %%%


===Using Specific Text===
===Using Specific Text===
===使用特定的文本===


Displays previous and next post links in the format with the text before the post title not shown as a link.
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:10px">Previous: Previous Post Title&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;Next: Next Post Title</div>
&lt;p&gt;<?php previous_post('%', 'Previous:', 'no'); ?>
| <?php next_post('%', 'Next:', 'no'); ?>&lt;/p&gt;


<div style="border:1px solid blue; width:50%; padding:10px">Previous: Previous Post Title&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;Next: Next Post Title</div>
<div style="border:1px solid blue; width:50%; padding:10px">Previous: Previous Post Title&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;Next: Next Post Title</div>
第43行: 第87行:


===Using Arrows Not Text===
===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:
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:10px">&laquo; &laquo; [[WordPress:#Examples|Previous Post Title]]&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;[[WordPress:#Examples|Next Post Title]] &raquo; &raquo;</div>
<div style="border:1px solid blue; width:50%; padding:10px">&laquo; &laquo; [[WordPress:#Examples|Previous Post Title]]&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;[[WordPress:#Examples|Next Post Title]] &raquo; &raquo;</div>
第50行: 第98行:
<pre><?php previous_post('&amp;laquo; &amp;laquo; %', '', 'yes'); ?>
<pre><?php previous_post('&amp;laquo; &amp;laquo; %', '', 'yes'); ?>
| <?php next_post('% &amp;raquo; &amp;raquo; ', '', 'yes'); ?></pre>
| <?php next_post('% &amp;raquo; &amp;raquo; ', '', 'yes'); ?></pre>
<div style="border:1px solid blue; width:50%; padding:10px">&laquo; &laquo; [[WordPress:#Examples|前一篇文章标题]]&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;[[WordPress:#Examples|下一篇文章标题]] &raquo; &raquo;</div>
<pre><?php previous_post('&amp;laquo; &amp;laquo; %', '', 'yes'); ?>
| <?php next_post('% &amp;raquo; &amp;raquo; ', '', 'yes'); ?></pre>


== Parameters ==
== 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>.
; 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>.
;格式:(''string'')链接的格式字符串。字符串中的<tt>'%'</tt>会被称为链接所取代,这样<tt>'Go to %'</tt>会产生"Go to <a href=..." 默认为<tt>'%'</tt>。
; previous : (''string'') Link text to display. Defaults to <tt>'previous post: '</tt>.
; previous : (''string'') Link text to display. Defaults to <tt>'previous post: '</tt>.
;前:(''string'')需要显示的链接文本。默认为<tt>'前一篇文章: '</tt>。
; title : (''string'') Indicates whether title should be used as link text. If set to <tt>'yes'</tt>, immediately follows '''previous''' (above). Options are:
; title : (''string'') Indicates whether title should be used as link text. If set to <tt>'yes'</tt>, immediately follows '''previous''' (above). Options are:
;标题:(''string'')暗示标题是否应该被用在链接文本。如果设置为<tt>'是的'</tt>,立马追随'''前''' (以上的)。选项有:
:* <tt>'yes'</tt> (Default)
:* <tt>'yes'</tt> (Default)
:* <tt>'no'</tt>
:* <tt>'no'</tt>
:* <tt>'是的'</tt> (默认)
:* <tt>'不是的'</tt>
; in_same_cat : (''string'') Indicates whether the previous 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:
; in_same_cat : (''string'') Indicates whether the previous 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:
; in_same_cat : (''string'')暗示前一篇文章链接是否必须与当前的文章链接在同一个类别中。参数在WordPress1.5.1.3版本及更高的版本中能够运行。如果文章列在几个类别中,会在母类别内显示文章,而不是在子类别内。选项是:
:* <tt>'yes'</tt>
:* <tt>'yes'</tt>
:* <tt>'no'</tt> (Default)
:* <tt>'no'</tt> (Default)
:* <tt>'是的'</tt>
:* <tt>'不是的'</tt> (默认)
; limitprev : (''integer'') Sets previous post link on numeric value of parameter (current post ID minus '''limitprev'''). Defaults to <tt>1</tt>. Default is recommended.
; limitprev : (''integer'') Sets previous post link on numeric value of parameter (current post ID minus '''limitprev'''). Defaults to <tt>1</tt>. Default is recommended.
; limitprev : (''整数'')将前一篇文章链接设置到参数数值(当前文章ID最小'''limitprev''')。默认为<tt>1</tt>。推荐默认设置。
; excluded_category : (''integer'' -or- ''string'') Numeric category ID(s) from which the previous post should not be listed. Separate multiple categories with an '<tt>and</tt>': <tt>'1 and 5 and 15'</tt>. There is no default. Parameter works with versions of WordPress 1.5.2 and above.
; excluded_category : (''integer'' -or- ''string'') Numeric category ID(s) from which the previous post should not be listed. Separate multiple categories with an '<tt>and</tt>': <tt>'1 and 5 and 15'</tt>. There is no default. Parameter works with versions of WordPress 1.5.2 and above.
; excluded_categories : (''integer'' –或者- ''string'')前一篇文章不应该列出的类别ID数字。用'<tt>和</tt>'分开多个类别;<tt>'1和 5 和15'</tt>。没有默认设置。参数在WordPress1.5.2版本以及更高的版本上能够运行。


== Related ==
== Related ==
== 相关的==
See also [[WordPress:Template Tags/next_post|next_post()]].
See also [[WordPress:Template Tags/next_post|next_post()]].
 
也看看[[WordPress:Template Tags/next_post|next_post()]]。
{{Tag Post Tags}}
{{Tag Post Tags}}


{{PHP Function Tag Footer}}
{{PHP Function Tag Footer}}
{{标签文章标签}}
{{PHP函数标签页底文字}}

2008年7月10日 (四) 11:27的版本

模板:Deprecated


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.



Description

描述

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

这个标签用在一篇单一的文章/permalink网页上,列出了在当前文章之前发表的文章。这个标签可以与next_post()标签一起运行。必须在The Loop内使用这个标签。

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

对于索引,类别,和归档模板,请使用posts_nav_link()标签。

Replace With

取代

previous_post_link().

previous_post_link().

Usage

用法

%%% <?php previous_post('format', 'previous', 'title', 'in_same_cat',

                   limitprev, excluded_category); ?> %%%

%%% <?php previous_post('format', 'previous', 'title', 'in_same_cat',

                   limitprev, excluded_category); ?> %%%

Examples

例子

Default Usage

默认用法

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

默认情况下,显示文本"前一篇文章:"与文章标题一起作为链接。

[[WordPress:#Examples|previous post: Previous Post Title]]
[[WordPress:#Examples|前一篇文章: 前一篇文章标题]]

%%% <?php previous_post(); ?> %%%

%%% <?php previous_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. "« Previous" is the specified text in this example; you can put whatever you want.

显示规定的文本作为链接,不包括文章标题。如果过长的文章标题破坏了你的布局,你可能想试试这个。"« 前一个"是这个例子中规定的文本;你可以剪除任何你想要剪除的内容。

[[WordPress:#Examples|« Previous]]

%%% <?php previous_post('%','« Previous', 'no'); ?> %%%

[[WordPress:#Examples|« 前一个]]

%%% <?php previous_post('%','« Previous', '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: Previous Post Title    |    Next: Next Post Title
<p><?php previous_post('%', 'Previous:', 'no'); ?> 
| <?php next_post('%', 'Next:', 'no'); ?></p>
Previous: Previous Post Title    |    Next: 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'); ?>


« « [[WordPress:#Examples|前一篇文章标题]]    |    [[WordPress:#Examples|下一篇文章标题]] » »
<?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 '%'.

;格式:(string)链接的格式字符串。字符串中的'%'会被称为链接所取代,这样'Go to %'会产生"Go to <a href=..." 默认为'%'

previous
(string) Link text to display. Defaults to 'previous post: '.
前:(string)需要显示的链接文本。默认为'前一篇文章: '
title
(string) Indicates whether title should be used as link text. If set to 'yes', immediately follows previous (above). Options are:

;标题:(string)暗示标题是否应该被用在链接文本。如果设置为'是的',立马追随 (以上的)。选项有:

  • 'yes' (Default)
  • 'no'
  • '是的' (默认)
  • '不是的'
in_same_cat
(string) Indicates whether the previous 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:
in_same_cat
(string)暗示前一篇文章链接是否必须与当前的文章链接在同一个类别中。参数在WordPress1.5.1.3版本及更高的版本中能够运行。如果文章列在几个类别中,会在母类别内显示文章,而不是在子类别内。选项是:


  • 'yes'
  • 'no' (Default)
  • '是的'
  • '不是的' (默认)
limitprev
(integer) Sets previous post link on numeric value of parameter (current post ID minus limitprev). Defaults to 1. Default is recommended.
limitprev
(整数)将前一篇文章链接设置到参数数值(当前文章ID最小limitprev)。默认为1。推荐默认设置。
excluded_category
(integer -or- string) Numeric category ID(s) from which the previous 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.
excluded_categories
(integer –或者- string)前一篇文章不应该列出的类别ID数字。用''分开多个类别;'1和 5 和15'。没有默认设置。参数在WordPress1.5.2版本以及更高的版本上能够运行。


Related

相关的

See also next_post(). 也看看next_post()模板:Tag Post Tags

模板:PHP Function Tag Footer 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,