WordPress: Template Tags/wp get archives:修订间差异
来自站长百科
无编辑摘要 |
无编辑摘要 |
||
第1行: | 第1行: | ||
== 描述 == | == 描述 == | ||
这个函数显示了按日期保存的存档,与[[WordPress:Template_Tags/get_archives|get_archives()]]排列的方式是相同的。唯一的不同点在于,参数自变量是以查询字符串的形式提交给函数的。必须在模板内的任何位置使用这个标签。 | |||
== 用法 == | |||
== | |||
%%% <?php wp_get_archives('arguments'); ?> %%% | %%% <?php wp_get_archives('arguments'); ?> %%% | ||
== | == 例子 == | ||
===默认用法=== | |||
=== | |||
%%% <?php $defaults = array( | %%% <?php $defaults = array( | ||
'type' => 'monthly', | 'type' => 'monthly', | ||
第25行: | 第17行: | ||
'show_post_count' => false); ?>%%% | 'show_post_count' => false); ?>%%% | ||
默认情况下,用法显示: | 默认情况下,用法显示: | ||
*按月归档,显示链接 | *按月归档,显示链接 | ||
*显示所有的存档(不限制数目) | *显示所有的存档(不限制数目) | ||
*以一个<nowiki><li></nowiki>HTML列表显示归档。 | *以一个<nowiki><li></nowiki>HTML列表显示归档。 | ||
*每个链接的前面或者后面不显示任何内容 | *每个链接的前面或者后面不显示任何内容 | ||
*不显示文章的数目 | *不显示文章的数目 | ||
===最后十二个月=== | ===最后十二个月=== | ||
按月显示归档列表,只显示最后十二个月的归档。 | 按月显示归档列表,只显示最后十二个月的归档。 | ||
%%%<?php wp_get_archives('type=monthly&limit=12'); ?>%%% | %%%<?php wp_get_archives('type=monthly&limit=12'); ?>%%% | ||
===最后十五天=== | ===最后十五天=== | ||
按天显示归档列表,只显示最后十五天的存档。 | 按天显示归档列表,只显示最后十五天的存档。 | ||
%%%<?php wp_get_archives('type=daily&limit=15'); ?>%%% | %%%<?php wp_get_archives('type=daily&limit=15'); ?>%%% | ||
===最后二十篇文章=== | ===最后二十篇文章=== | ||
显示文章标题列出的最后二十篇最近的文章的归档列表。 | 显示文章标题列出的最后二十篇最近的文章的归档列表。 | ||
%%%<?php wp_get_archives('type=postbypost&limit=20&format=custom'); ?>%%% | %%%<?php wp_get_archives('type=postbypost&limit=20&format=custom'); ?>%%% | ||
===下拉列表框=== | ===下拉列表框=== | ||
显示按月归档的一个下拉列表框,在选择标签中,显示了文章数目。 | 显示按月归档的一个下拉列表框,在选择标签中,显示了文章数目。 | ||
第104行: | 第52行: | ||
<?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select> | <?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select> | ||
%%% | %%% | ||
== 参数 == | == 参数 == | ||
; type | ; type : (''string'') 需要显示的存档列表的类型。默认为WordPress设置。有效的参数值: | ||
:* <tt>yearly</tt> | :* <tt>yearly</tt> | ||
:* <tt>monthly</tt> (Default) | :* <tt>monthly</tt> (Default) | ||
第127行: | 第62行: | ||
:* <tt>postbypost</tt> | :* <tt>postbypost</tt> | ||
; limit : (''integer'') 得到的存档的数目。默认没有数目限制。 | |||
; format : (''string'') 归档列表的格式。有效的参数值: | |||
:* <tt>html</tt> - 在HTML列表(<li>)标签和'''之前''' 和'''之后'''字符串中。这是默认的。 | |||
:* <tt>option</tt> - 在选择(<选择>)或者下拉列表选项(<选项>)标签中。 | |||
:* <tt>html</tt> -在HTML列表(<li>)标签和'''之前''' 和'''之后'''字符串中。这是默认的。 | |||
:* <tt>option | |||
:* <tt>link</tt> - Within link (<link>) tags. | :* <tt>link</tt> - Within link (<link>) tags. | ||
:* <tt>custom</tt> - 使用'''之前''' 和 '''之后'''自定义列表。 | |||
; before : (''string'') 为'''格式'''选项使用<tt>html</tt>或者<tt>自定义</tt>时,放置在链接之前的文本。 | |||
; after : (''string'') 为'''格式'''选项使用<tt>html</tt>或者<tt>自定义</tt>时,放置在链接之后的文本。没有默认设置。 | |||
; show_post_count : (''boolean'')在一个归档(<tt>1</tt> - true)中,显示文章的数目,或者不显示文章数目(<tt>0</tt> - false)。使用所有'''类型''',<tt>'一篇文章接着一篇文章'</tt>这种类型,除外。 | |||
== 相关的== | == 相关的== |
2008年7月13日 (日) 15:28的最新版本
描述[ ]
这个函数显示了按日期保存的存档,与get_archives()排列的方式是相同的。唯一的不同点在于,参数自变量是以查询字符串的形式提交给函数的。必须在模板内的任何位置使用这个标签。
用法[ ]
%%% <?php wp_get_archives('arguments'); ?> %%%
例子[ ]
默认用法[ ]
%%% <?php $defaults = array(
'type' => 'monthly', 'limit' => , 'format' => 'html', 'before' => , 'after' => , 'show_post_count' => false); ?>%%%
默认情况下,用法显示:
- 按月归档,显示链接
- 显示所有的存档(不限制数目)
- 以一个<li>HTML列表显示归档。
- 每个链接的前面或者后面不显示任何内容
- 不显示文章的数目
最后十二个月[ ]
按月显示归档列表,只显示最后十二个月的归档。
%%%<?php wp_get_archives('type=monthly&limit=12'); ?>%%%
最后十五天[ ]
按天显示归档列表,只显示最后十五天的存档。
%%%<?php wp_get_archives('type=daily&limit=15'); ?>%%%
最后二十篇文章[ ]
显示文章标题列出的最后二十篇最近的文章的归档列表。
%%%<?php wp_get_archives('type=postbypost&limit=20&format=custom'); ?>%%%
下拉列表框[ ]
显示按月归档的一个下拉列表框,在选择标签中,显示了文章数目。
%%% <select name="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=""><?php echo attribute_escape(__('Select Month')); ?></option> <?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select>
%%%
参数[ ]
- type
- (string) 需要显示的存档列表的类型。默认为WordPress设置。有效的参数值:
- yearly
- monthly (Default)
- daily
- weekly
- postbypost
- limit
- (integer) 得到的存档的数目。默认没有数目限制。
- format
- (string) 归档列表的格式。有效的参数值:
- html - 在HTML列表(<li>)标签和之前 和之后字符串中。这是默认的。
- option - 在选择(<选择>)或者下拉列表选项(<选项>)标签中。
- link - Within link (<link>) tags.
- custom - 使用之前 和 之后自定义列表。
- before
- (string) 为格式选项使用html或者自定义时,放置在链接之前的文本。
- after
- (string) 为格式选项使用html或者自定义时,放置在链接之后的文本。没有默认设置。
- show_post_count
- (boolean)在一个归档(1 - true)中,显示文章的数目,或者不显示文章数目(0 - false)。使用所有类型,'一篇文章接着一篇文章'这种类型,除外。