Title: WP_HTML_Open_Elements::current_node
Published: November 8, 2023
Last modified: February 24, 2026

---

# WP_HTML_Open_Elements::current_node(): 󠀁[WP_HTML_Token](https://developer.wordpress.org/reference/classes/wp_html_token/)󠁿|null

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_html_open_elements/current_node/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_html_open_elements/current_node/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_html_open_elements/current_node/?output_format=md#changelog)

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

Returns the node at the end of the stack of open elements, if one exists. If the
stack is empty, returns null.

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

 [WP_HTML_Token](https://developer.wordpress.org/reference/classes/wp_html_token/)
|null Last node in the stack of open elements, if one exists, otherwise null.

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

    ```php
     */
    public function current_node(): ?WP_HTML_Token {
    	$current_node = end( $this->stack );

    	return $current_node ? $current_node : null;
    ```

[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/7.0/src/wp-includes/html-api/class-wp-html-open-elements.php#L184)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/html-api/class-wp-html-open-elements.php#L184-L188)

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

| Version | Description | 
| [6.4.0](https://developer.wordpress.org/reference/since/6.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_html_open_elements%2Fcurrent_node%2F)
before being able to contribute a note or feedback.