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

---

# WP_HTML_Open_Elements::current_node_is( string $identity ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_html_open_elements/current_node_is/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/classes/wp_html_open_elements/current_node_is/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_html_open_elements/current_node_is/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_html_open_elements/current_node_is/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_html_open_elements/current_node_is/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_html_open_elements/current_node_is/?output_format=md#changelog)

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

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Indicates if the current node is of a given type or name.

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

It’s possible to pass either a node type or a node name to this function.
In the
case there is no current element it will always return `false`.

Example:

    ```php
    // Is the current node a text node?
    $stack->current_node_is( '#text' );

    // Is the current node a DIV element?
    $stack->current_node_is( 'DIV' );

    // Is the current node any element/tag?
    $stack->current_node_is( '#tag' );
    ```

### 󠀁[See also](https://developer.wordpress.org/reference/classes/wp_html_open_elements/current_node_is/?output_format=md#see-also)󠁿

 * [WP_HTML_Tag_Processor::get_token_type](https://developer.wordpress.org/reference/classes/WP_HTML_Tag_Processor/get_token_type/)
 * [WP_HTML_Tag_Processor::get_token_name](https://developer.wordpress.org/reference/classes/WP_HTML_Tag_Processor/get_token_name/)

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

 `$identity`stringrequired

Check if the current node has this name or type (depending on what is provided).

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

 bool Whether there is a current element that matches the given identity, whether
a token name or type.

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

    ```php
    public function current_node_is( string $identity ): bool {
    	$current_node = end( $this->stack );
    	if ( false === $current_node ) {
    		return false;
    	}

    	$current_node_name = $current_node->node_name;

    	return (
    		$current_node_name === $identity ||
    		( '#doctype' === $identity && 'html' === $current_node_name ) ||
    		( '#tag' === $identity && ctype_upper( $current_node_name ) )
    	);
    }
    ```

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

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

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