Title: WP_Customize_Manager::set_autofocus
Published: December 9, 2015
Last modified: February 24, 2026

---

# WP_Customize_Manager::set_autofocus( array $autofocus )

## In this article

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

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

Sets the autofocused constructs.

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

 `$autofocus`arrayrequired

Mapping of ‘panel’, ‘section’, ‘control’ to the ID which should be autofocused.

 * `control` string
 * ID for control to be autofocused.
 * `section` string
 * ID for section to be autofocused.
 * `panel` string
 * ID for panel to be autofocused.

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

    ```php
    public function set_autofocus( $autofocus ) {
    	$this->autofocus = array_filter( wp_array_slice_assoc( $autofocus, array( 'panel', 'section', 'control' ) ), 'is_string' );
    }
    ```

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

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

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

Extracts a slice of an array, given a list of keys.

  |

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

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

## User Contributed Notes

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