钩子文档

widget_archives_args

💡 云策文档标注

概述

widget_archives_args 是一个 WordPress 过滤器,用于修改 Archives 小工具的参数。它允许开发者在输出归档内容前自定义参数数组。

关键要点

  • 这是一个过滤器 Hook,名称为 widget_archives_args。
  • 接收两个参数:$args(归档选项参数数组)和 $instance(当前小工具设置数组)。
  • 与 wp_get_archives() 函数相关,用于控制归档显示方式。
  • 在 WordPress 4.9.0 版本中增加了 $instance 参数,2.8.0 版本引入。

代码示例

apply_filters(
    'widget_archives_args',
    array(
        'type'            => 'monthly',
        'show_post_count' => $count,
    ),
    $instance
)

📄 原文内容

Filters the arguments for the Archives widget.

Description

See also

Parameters

$argsarray
An array of Archives option arguments.
$instancearray
Array of settings for the current widget.

Source

apply_filters(
	'widget_archives_args',
	array(
		'type'            => 'monthly',
		'show_post_count' => $count,
	),
	$instance
)

Changelog

Version Description
4.9.0 Added the $instance parameter.
2.8.0 Introduced.