首页 > php > wordpress wp_get_archives函数详解

wordpress wp_get_archives函数详解

2010年6月28日 亲亲宝宝 发表评论 阅读评论

该标签显示一个基于日期的存档列表。参数变量以查询字符串形式传递给该标签。wp_get_archives()可用在模板中的任何位置。
<?php wp_get_archives(‘type=monthly&format=html&show_post_count=true’); ?>
意思是按月归档,以<li>HTML列表形式,显示文章数量.
默认设置:
<?php $args = array(
    ‘type’            => ‘monthly’,
    ‘limit’           => ,
    
‘format’          => ‘html’
    
‘before’          => ,
    ‘after’           => ,
    
‘show_post_count’ => false,
    
‘echo’            => ); ?>

默认情况下的显示状态:

  • 按月显示存档链接
  • 显示所有存档文章(没有数量限制)
  • 以<li>HTML列表形式显示存档
  • 存档链接前后不显示任何内容
  • 不显示存档下的文章总数

参数详细说明:

type

(字符串)将要显示的存档列表的类型。默认遵循WordPress的设置。有效值包括:

  • yearly
  • monthly ——默认值
  • daily
  • weekly
  • postbypost (以发表日期为顺序排列日志)
  • alpha (与postbypost相同,但以日志标题为顺序排列日志)

limit

(整数)可获取的存档数量。默认为无限制。

format

(字符串)存档列表的格式。有效值包括:

  • html —— 在HTML 列表(<li>)标签与beforeafter字符串内。默认值。
  • option —— 在选择符(<select>)或下拉式选项(<option>)标签中。
  • link —— 在链接(<link>)标签中
  • custom list—— 使用beforeafter字符串的自定义列表

before

(字符串)当format值为html或custom时,放在链接前的文字。无默认值。

after

(字符串)当format值为html或custom时,放在链接后的文字。无默认值。

show_post_count

(字符串)是否显示存档中的文章总数。用于’postbypost’外所有类型。

  • 1 (true)
  • 0(false)——默认值

echo

(布尔型)显示结果或返回。

  • 1 (true)——默认值
  • 0(false)
分类: php 标签: 5,616 次阅读
原文链接:http://www.wenhq.com/article/view_622.html
欢迎转载,请注明出处:亲亲宝宝
  1. 2010年7月1日11:31 | #1

    博主的博客不错,经常收看了欢迎来我的网站踩踩:韩版童装批发网

    [回复]

  1. 本文目前尚无任何 trackbacks 和 pingbacks.