WordPress: Template Tags/get archives:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: {{Deprecated}} == Description == Displays a list of links to date-based archives. This tag can be used anywhere within a template. It is similar to [[WordPress:Template_Tags/wp_get_arch...)
 
无编辑摘要
第1行: 第1行:
{{Deprecated}}
{{Deprecated}}
== Description ==
== Description ==
{{取消}}
== 描述 ==


Displays a list of links to date-based archives. This tag can be used anywhere within a template.  It is similar to [[WordPress:Template_Tags/wp_get_archives|wp_get_archives()]].
Displays a list of links to date-based archives. This tag can be used anywhere within a template.  It is similar to [[WordPress:Template_Tags/wp_get_archives|wp_get_archives()]].
向按日的存档显示一列链接。可以在一个模板内的任何位置使用这个标签。这个标签与[[WordPress:Template_Tags/wp_get_archives|wp_得到_存档()]]标签类似。


== Replace With ==
== Replace With ==
== 取代 ==


[[WordPress:Template Tags/wp_get_archives|wp_get_archives()]].
[[WordPress:Template Tags/wp_get_archives|wp_get_archives()]].
[[WordPress:Template Tags/wp_get_archives|wp_得到_归档()]]。


== Usage ==
== Usage ==


%%% <?php get_archives('type', 'limit', 'format', 'before', 'after', show_post_count); ?> %%%
%%% <?php get_archives('type', 'limit', 'format', 'before', 'after', show_post_count); ?> %%%
== 用法 ==
%%% <?php get_archives('type', 'limit', 'format', 'before', 'after', show_post_count); ?> %%%
%%% <?php 得到_归档('输入', '限制', '格式', '之前', '之后', 显示_文章_数目); ?> %%%


== Examples ==
== Examples ==


=== Default Usage ===
=== Default Usage ===
== 例子==
=== 默认用法 ===


Displays archive links using defaults.
Displays archive links using defaults.
使用默认设置,显示归档链接。
<?php get_archives(); ?>


<?php get_archives(); ?>
<?php 得到_归档(); ?>




=== By Month with Post Count ===
=== By Month with Post Count ===
=== 按月归档,显示文章数目===


Displays all archives by month in an unordered list, with count of posts by month.
Displays all archives by month in an unordered list, with count of posts by month.
   
   
在一个无序列表上显示所有的归档,按月显示文章的数目。
  &lt;ul&gt;
  &lt;ul&gt;
  <?php get_archives('monthly', &#39;&#39;, 'html', &#39;&#39;, &#39;&#39;, TRUE); ?>
  <?php get_archives('monthly', &#39;&#39;, 'html', &#39;&#39;, &#39;&#39;, TRUE); ?>
&lt;/ul&gt;
&lt;ul&gt;
<?php 得到_归档('按月', &#39;&#39;, 'html', &#39;&#39;, &#39;&#39;, TRUE); ?>
  &lt;/ul&gt;
  &lt;/ul&gt;




=== Displays Last 10 Posts In A List ===
=== Displays Last 10 Posts In A List ===
=== 在一个列表上显示最近十篇文章===


Displays a non-bulleted list of the last 10 posts separated by line breaks.
Displays a non-bulleted list of the last 10 posts separated by line breaks.
将十篇最近的文章按行分开,显示在一个没有bullet符号的列表上。


  <?php get_archives('postbypost', '10', 'custom', &#39;&#39;, '&lt;br /&gt;'); ?>
  <?php get_archives('postbypost', '10', 'custom', &#39;&#39;, '&lt;br /&gt;'); ?>
<?php 得到_归档('一篇文章接着一篇文章', '10', '自定义', &#39;&#39;, '&lt;br /&gt;'); ?>


=== Using Dropdown List ===
=== Using Dropdown List ===
=== 使用下拉列表===


Displays monthly archives in a dropdown list; the use of [[WordPress:Glossary#JavaScript|javascript]] is required to have an archive selection open on the page.
Displays monthly archives in a dropdown list; the use of [[WordPress:Glossary#JavaScript|javascript]] is required to have an archive selection open on the page.
在一个下拉列表上显示按月的归档;需要使用[[WordPress:Glossary#JavaScript|javascript]],以在网页上拥有一个打开的归档选择。


  &lt;form id="archiveform" action=""&gt;
  &lt;form id="archiveform" action=""&gt;
&lt;select name="archive_chrono" onchange="window.location =
(document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);"&gt;
&lt;option value=&#39;&#39;>Select Month</option>
<?php get_archives('monthly',&#39;&#39;,'option'); ?>
&lt;/select&gt;
&lt;/form&gt;
&lt;form id="archiveform" action=""&gt;
  &lt;select name="archive_chrono" onchange="window.location =
  &lt;select name="archive_chrono" onchange="window.location =
  (document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);"&gt;
  (document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);"&gt;
第49行: 第98行:


You also can use piece of code below, that works better than the example above. It shows the months list, including the number of posts/month.
You also can use piece of code below, that works better than the example above. It shows the months list, including the number of posts/month.
你也可以使用下面的这个代码,比上面的例子中的代码,运行地更好。这个代码显示了按月归档的列表,同时显示了每月的归档文章的数目。


   <select name="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;">
   <select name="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;">
   <option value="">Select month</option>
   <option value="">Select month</option>
  <?php get_archives('monthly','','option','','','TRUE'); ?>
  </select>
  <选择 名称="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;">
  <option value="">选择月份</option>
   <?php get_archives('monthly','','option','','','TRUE'); ?>
   <?php get_archives('monthly','','option','','','TRUE'); ?>
   </select>
   </select>


=== List of Limited Number of Recent Posts ===
=== List of Limited Number of Recent Posts ===
=== List of Limited Number of Recent Posts ===
=== 有限个最近文章的列表===


Displays a custom number of recent posts in an unordered list.
Displays a custom number of recent posts in an unordered list.


   &lt;ul&gt;<?php get_archives('postbypost','10','custom','&lt;li&gt;','&lt;/li&gt;'); ?>&lt;/ul&gt;
在一个无序列表上显示自定义数目最近文章的列表。
 
   &lt;ul&gt;<?php  
&lt;ul&gt;<?php
get_archives('postbypost','10','custom','&lt;li&gt;','&lt;/li&gt;'); ?>&lt;/ul&gt;
 
 
得到_归档啊('一篇文章接着一篇文章','10','自定义','&lt;li&gt;','&lt;/li&gt;'); ?>&lt;/ul&gt;




== Parameters ==
== Parameters ==
== 参数 ==


; type : (''string'') The type of archive list to display. Defaults to WordPress setting (defaults to <tt>'monthly'</tt> in 1.5). Valid values:
; type : (''string'') The type of archive list to display. Defaults to WordPress setting (defaults to <tt>'monthly'</tt> in 1.5). Valid values:
; 类型 : (''string'')需要显示的归档列表的类型。默认为WordPress设置(在1.5版本中默认为<tt>'按月'</tt>)。有效的参数值:
:* <tt>'monthly'</tt> (Default)
:* <tt>'monthly'</tt> (Default)
:* <tt>'daily'</tt>
:* <tt>'daily'</tt>
:* <tt>'weekly'</tt>
:* <tt>'weekly'</tt>
:* <tt>'postbypost'</tt>
:* <tt>'postbypost'</tt>
:* <tt>'按月'</tt> (默认)
:* <tt>'每日'</tt>
:* <tt>'每周'</tt>
:* <tt>'一篇文章接着一篇文章'</tt>
; limit : (''integer'') Number of archives to get.  Use <tt>&#39;&#39;</tt> for no limit.
; limit : (''integer'') Number of archives to get.  Use <tt>&#39;&#39;</tt> for no limit.
; 限制 : (''整数'')得到的存档文章的数目。使用<tt>&#39;&#39;</tt>,没有限制。
; format : (''string'') Format for the archive list. Valid values:
; format : (''string'') Format for the archive list. Valid values:
;样式 : (''string'')存档列表的样式。有效的参数值:
:* <tt>'html'</tt> - In HTML list (&lt;li&gt;) tags. This is the default.
:* <tt>'html'</tt> - In HTML list (&lt;li&gt;) tags. This is the default.
:* <tt>'html'</tt> -在HTML列表(&lt;li&gt;)标签中。这是默认设置的。
:* <tt>'option'</tt> - In select or dropdown option (&lt;option&gt;) tags.
:* <tt>'option'</tt> - In select or dropdown option (&lt;option&gt;) tags.
:* <tt>'选项'</tt> -在精选的或者下拉列表选项(&lt;option&gt;)标签。
:* <tt>'link'</tt> - Within link (&lt;link&gt;) tags.  
:* <tt>'link'</tt> - Within link (&lt;link&gt;) tags.  
:* <tt>'链接'</tt> -在链接(&lt;链接&gt;)标签内部。
:* <tt>'custom'</tt> - Custom list.
:* <tt>'custom'</tt> - Custom list.
:* <tt>'自定义'</tt> -自定义列表。
; before : (''string'') Text to place before the link when using <tt>'custom'</tt> or <tt>'html'</tt> for '''format''' option. Defaults to <tt>&#39;&#39;</tt>.
; before : (''string'') Text to place before the link when using <tt>'custom'</tt> or <tt>'html'</tt> for '''format''' option. Defaults to <tt>&#39;&#39;</tt>.
; 之前 : (''string'')为'''格式'''选项使用<tt>'自定义'</tt> 或者<tt>'html'</tt>时,在链接前显示的文本。默认为<tt>&#39;&#39;</tt>。
; after : (''string'') Text to place after the link when using <tt>'custom'</tt> or <tt>'html'</tt> for '''format''' option.  Defaults to <tt>&#39;&#39;</tt>.
; after : (''string'') Text to place after the link when using <tt>'custom'</tt> or <tt>'html'</tt> for '''format''' option.  Defaults to <tt>&#39;&#39;</tt>.
; 之后 : (''string'') 为'''格式'''选项使用<tt>'自定义'</tt> 或者<tt>'html'</tt>时,在链接后显示的文本。默认为<tt>&#39;&#39;</tt>。
; show_post_count : (''boolean'') Display number of posts in an archive (<tt>TRUE</tt>) or do not (<tt>FALSE</tt>). For use when '''type''' is set to <tt>'monthly'</tt>. Defaults to <tt>FALSE</tt>.
; show_post_count : (''boolean'') Display number of posts in an archive (<tt>TRUE</tt>) or do not (<tt>FALSE</tt>). For use when '''type''' is set to <tt>'monthly'</tt>. Defaults to <tt>FALSE</tt>.
; 显示_文章_数目 : (''boolean'')显示一个存档中的文章数目(<tt>正确的</tt>)或者不显示(<tt>错误的</tt>)。当'''类型'''设置为<tt>'每月'</tt>的时候,可以使用。默认为<tt>错误的</tt>。


== Related ==
== Related ==
== 相关的==
To use the query string to pass parameters to generate an archive list, see [[WordPress:Template_Tags/wp_get_archives|wp_get_archives()]]
To use the query string to pass parameters to generate an archive list, see [[WordPress:Template_Tags/wp_get_archives|wp_get_archives()]]
要使用查询字符串,传递参数,产生一个归档列表,请看看[[WordPress:Template_Tags/wp_get_archives|wp_得到_归档()]]


{{Tag General Tags}}
{{Tag General Tags}}


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

2008年7月3日 (四) 15:48的版本

模板:Deprecated

Description

模板:取消

描述

Displays a list of links to date-based archives. This tag can be used anywhere within a template. It is similar to wp_get_archives().

向按日的存档显示一列链接。可以在一个模板内的任何位置使用这个标签。这个标签与wp_得到_存档()标签类似。

Replace With

取代

wp_get_archives().

wp_得到_归档()

Usage

%%% <?php get_archives('type', 'limit', 'format', 'before', 'after', show_post_count); ?> %%%

用法

%%% <?php get_archives('type', 'limit', 'format', 'before', 'after', show_post_count); ?> %%%

%%% <?php 得到_归档('输入', '限制', '格式', '之前', '之后', 显示_文章_数目); ?> %%%

Examples

Default Usage

例子

默认用法

Displays archive links using defaults. 使用默认设置,显示归档链接。

<?php get_archives(); ?>


<?php 得到_归档(); ?>


By Month with Post Count

按月归档,显示文章数目

Displays all archives by month in an unordered list, with count of posts by month.

在一个无序列表上显示所有的归档,按月显示文章的数目。

<ul>
<?php get_archives('monthly', '', 'html', '', '', TRUE); ?>
</ul>


<ul>

<?php 得到_归档('按月', '', 'html', '', '', TRUE); ?>
</ul>


Displays Last 10 Posts In A List

在一个列表上显示最近十篇文章

Displays a non-bulleted list of the last 10 posts separated by line breaks.

将十篇最近的文章按行分开,显示在一个没有bullet符号的列表上。

<?php get_archives('postbypost', '10', 'custom', '', '<br />'); ?>

<?php 得到_归档('一篇文章接着一篇文章', '10', '自定义', '', '<br />'); ?>

Using Dropdown List

使用下拉列表

Displays monthly archives in a dropdown list; the use of javascript is required to have an archive selection open on the page.

在一个下拉列表上显示按月的归档;需要使用javascript,以在网页上拥有一个打开的归档选择。

<form id="archiveform" action="">
<select name="archive_chrono" onchange="window.location =
(document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);">
<option value=''>Select Month</option>
<?php get_archives('monthly','','option'); ?>
</select>
</form>

<form id="archiveform" action="">

<select name="archive_chrono" onchange="window.location =
(document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);">
<option value=''>Select Month</option>
<?php get_archives('monthly','','option'); ?>
</select>
</form>

You also can use piece of code below, that works better than the example above. It shows the months list, including the number of posts/month.

你也可以使用下面的这个代码,比上面的例子中的代码,运行地更好。这个代码显示了按月归档的列表,同时显示了每月的归档文章的数目。

 <select name="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;">
 <option value="">Select month</option>
 <?php get_archives('monthly',,'option',,,'TRUE'); ?>
 </select>
 <选择 名称="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;">
 <option value="">选择月份</option>
 <?php get_archives('monthly',,'option',,,'TRUE'); ?>
 </select>

List of Limited Number of Recent Posts

List of Limited Number of Recent Posts

有限个最近文章的列表

Displays a custom number of recent posts in an unordered list.

在一个无序列表上显示自定义数目最近文章的列表。

 <ul><?php 

<ul><?php get_archives('postbypost','10','custom','<li>','</li>'); ?></ul>


得到_归档啊('一篇文章接着一篇文章','10','自定义','<li>','</li>'); ?></ul>


Parameters

参数

type
(string) The type of archive list to display. Defaults to WordPress setting (defaults to 'monthly' in 1.5). Valid values:
类型
(string)需要显示的归档列表的类型。默认为WordPress设置(在1.5版本中默认为'按月')。有效的参数值:
  • 'monthly' (Default)
  • 'daily'
  • 'weekly'
  • 'postbypost'


  • '按月' (默认)
  • '每日'
  • '每周'
  • '一篇文章接着一篇文章'
limit
(integer) Number of archives to get. Use '' for no limit.
限制
(整数)得到的存档文章的数目。使用'',没有限制。
format
(string) Format for the archive list. Valid values:
样式
(string)存档列表的样式。有效的参数值:
  • 'html' - In HTML list (<li>) tags. This is the default.
  • 'html' -在HTML列表(<li>)标签中。这是默认设置的。
  • 'option' - In select or dropdown option (<option>) tags.
  • '选项' -在精选的或者下拉列表选项(<option>)标签。
  • 'link' - Within link (<link>) tags.
  • '链接' -在链接(<链接>)标签内部。
  • 'custom' - Custom list.
  • '自定义' -自定义列表。
before
(string) Text to place before the link when using 'custom' or 'html' for format option. Defaults to ''.
之前
(string)为格式选项使用'自定义' 或者'html'时,在链接前显示的文本。默认为''
after
(string) Text to place after the link when using 'custom' or 'html' for format option. Defaults to ''.
之后
(string) 为格式选项使用'自定义' 或者'html'时,在链接后显示的文本。默认为''
show_post_count
(boolean) Display number of posts in an archive (TRUE) or do not (FALSE). For use when type is set to 'monthly'. Defaults to FALSE.
显示_文章_数目
(boolean)显示一个存档中的文章数目(正确的)或者不显示(错误的)。当类型设置为'每月'的时候,可以使用。默认为错误的

Related

相关的

To use the query string to pass parameters to generate an archive list, see wp_get_archives()

要使用查询字符串,传递参数,产生一个归档列表,请看看wp_得到_归档()

模板:Tag General Tags

模板:PHP Function Tag Footer

模板:标签 总 标签

模板:PHP 函数 标签 页底文字