Title: WP_Widget_Archives::update
Published: April 25, 2014
Last modified: February 24, 2026

---

# WP_Widget_Archives::update( array $new_instance, array $old_instance ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_widget_archives/update/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_widget_archives/update/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_widget_archives/update/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_widget_archives/update/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_widget_archives/update/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_widget_archives/update/?output_format=md#wp--skip-link--target)

Handles updating settings for the current Archives widget instance.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_widget_archives/update/?output_format=md#parameters)󠁿

 `$new_instance`arrayrequired

New settings for this instance as input by the user via [WP_Widget_Archives::form()](https://developer.wordpress.org/reference/classes/wp_widget_archives/form/).

`$old_instance`arrayrequired

Old settings for this instance.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_widget_archives/update/?output_format=md#return)󠁿

 array Updated settings to save.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_widget_archives/update/?output_format=md#source)󠁿

    ```php
    public function update( $new_instance, $old_instance ) {
    	$instance             = $old_instance;
    	$new_instance         = wp_parse_args(
    		(array) $new_instance,
    		array(
    			'title'    => '',
    			'count'    => 0,
    			'dropdown' => '',
    		)
    	);
    	$instance['title']    = sanitize_text_field( $new_instance['title'] );
    	$instance['count']    = $new_instance['count'] ? 1 : 0;
    	$instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0;

    	return $instance;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/widgets/class-wp-widget-archives.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/widgets/class-wp-widget-archives.php#L200)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/widgets/class-wp-widget-archives.php#L200-L215)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_widget_archives/update/?output_format=md#related)󠁿

| Uses | Description | 
| [sanitize_text_field()](https://developer.wordpress.org/reference/functions/sanitize_text_field/)`wp-includes/formatting.php` |

Sanitizes a string from user input or from the database.

  | 
| [wp_parse_args()](https://developer.wordpress.org/reference/functions/wp_parse_args/)`wp-includes/functions.php` |

Merges user defined arguments into defaults array.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_widget_archives/update/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.8.0](https://developer.wordpress.org/reference/since/2.8.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_widget_archives%2Fupdate%2F)
before being able to contribute a note or feedback.