Title: WP_HTML_Open_Elements::set_pop_handler
Published: February 24, 2026

---

# WP_HTML_Open_Elements::set_pop_handler( Closure $handler )

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_html_open_elements/set_pop_handler/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_html_open_elements/set_pop_handler/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_html_open_elements/set_pop_handler/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_html_open_elements/set_pop_handler/?output_format=md#changelog)

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

Sets a pop handler that will be called when an item is popped off the stack of open
elements.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_html_open_elements/set_pop_handler/?output_format=md#description)󠁿

The function will be called with the pushed item as its argument.

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

 `$handler`Closurerequired

The handler function.

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

    ```php
    public function set_pop_handler( Closure $handler ): void {
    	$this->pop_handler = $handler;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/html-api/class-wp-html-open-elements.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/html-api/class-wp-html-open-elements.php#L86)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/html-api/class-wp-html-open-elements.php#L86-L88)

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

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

## User Contributed Notes

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