钩子文档

widget_archives_dropdown_args

💡 云策文档标注

概述

widget_archives_dropdown_args 是一个 WordPress 过滤器,用于修改 Archives 小部件下拉菜单的参数。它允许开发者在生成下拉菜单时自定义参数数组。

关键要点

  • 这是一个过滤器,用于 Archives 小部件的下拉菜单参数。
  • 接受两个参数:$args(参数数组)和 $instance(当前小部件实例设置)。
  • 在 WP_Widget_Archives::widget() 方法中被调用。
  • 从 WordPress 2.8.0 版本引入,4.9.0 版本添加了 $instance 参数。

代码示例

$dropdown_args = apply_filters(
    'widget_archives_dropdown_args',
    array(
        'type'            => 'monthly',
        'format'          => 'option',
        'show_post_count' => $count,
    ),
    $instance
);

注意事项

使用此过滤器时,需确保返回的参数数组符合 wp_get_archives() 函数的要求,以避免功能异常。


📄 原文内容

Filters the arguments for the Archives widget drop-down.

Description

See also

Parameters

$argsarray
An array of Archives widget drop-down arguments.
$instancearray
Settings for the current Archives widget instance.

Source

$dropdown_args = apply_filters(
	'widget_archives_dropdown_args',
	array(
		'type'            => 'monthly',
		'format'          => 'option',
		'show_post_count' => $count,
	),
	$instance
);

Changelog

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