wordpress模板标签/wp get archives
-描述:
该函数和get_archives()类似显示一个基于时间的归档列表。区别在于参数是以查询字符串的格式赋给函数。这个标签可以在一个模板中任何地方用。
-使用:
<?php wp_get_archives( $args ); ?>
<?php $args = array(
‘type’ => ‘monthly’, /*按月显示归档链接*/
‘limit’ => , /*显示所有归档*/
‘format’ => ‘html’, /*在<li>html列表中显示归档*/
‘before’ => ,
‘after’ => , /*在链接前或后不显示任何东西*/
’show_post_count’ => false, /*不显示文章统计*/
‘echo’ => 1 ); ?>
‘type’ => ‘monthly’, /*按月显示归档链接*/
‘limit’ => , /*显示所有归档*/
‘format’ => ‘html’, /*在<li>html列表中显示归档*/
‘before’ => ,
‘after’ => , /*在链接前或后不显示任何东西*/
’show_post_count’ => false, /*不显示文章统计*/
‘echo’ => 1 ); ?>
(字符串)归档显示的类型。
yearly -按年;
monthly -按月(默认);
daily -按天;
weekly -按周;
postbypost -按文章先后
(整数)要获取的归档数。默认不限制。
(字符串)归档列表的格式。
html -在html列表标签<li>与before和after字符串内。(默认)
option -在选择<select>或者下拉选项<option>标签内
link -在链接<link>标签内
custom -借助before和after字符串自定义列表
(字符串)当在上面format使用html或custom时,链接前的文本。没有默认值。
(字符串)当在上面format使用html或custom时,链接后的文本。没有默认值。
(布尔)是否在归档中显示文章数量。适用于参数type不为postbypost时。
(布尔)显示输出结果,1(显示-默认)0(不显示)。
-例子:
1.按月显示最近12个月归档。
<?php wp_get_archives(‘type=monthly&limit=12′); ?>
2.按日期(日)显示最近15天归档。
<?php wp_get_archives(‘type=daily&limit=15′); ?>
3.按文章标题显示最近20篇文章的归档。
<?php wp_get_archives(‘type=postbypost&limit=20&format=custom’); ?>
4.显示一个下拉选择框,框内归档按月,并附有文章统计。
<select name=”archive-dropdown”
onChange=’document.location.href=this.options[this.selectedIndex].value;’><option value=”"><?php echo attribute_escape(__(‘Select Month’)); ?>
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>
这里有英文原版文档。
右上方更多相关内容/站内搜索-关键词请用空格隔开
发表留言