函数文档

get_archives()

💡 云策文档标注

概述

get_archives() 是一个已弃用的 WordPress 函数,用于检索存档列表,现推荐使用 wp_get_archives() 替代。

关键要点

  • 函数已弃用:自 WordPress 2.1.0 起,get_archives() 被标记为弃用,应改用 wp_get_archives()。
  • 参数传递:函数接受 $type、$limit、$format、$before、$after 和 $show_post_count 等参数,并内部转换为数组传递给 wp_get_archives()。
  • 返回值:返回字符串或 null,具体取决于 wp_get_archives() 的输出。

注意事项

使用此函数会触发 _deprecated_function() 警告,建议在开发中直接使用 wp_get_archives() 以避免兼容性问题。


📄 原文内容

Retrieves a list of archives.

Description

See also

Parameters

$typestringrequired
$limitstringrequired
$formatstringrequired
$beforestringrequired
$afterstringrequired
$show_post_countbooloptional

Default:false

Return

string|null

Source

function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
	_deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_archives()' );
	$args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count');
	return wp_get_archives($args);
}

Changelog

Version Description
2.1.0 Deprecated. Use wp_get_archives()
0.71 Introduced.