Title: WP_Block_List::key
Published: August 11, 2020
Last modified: May 20, 2026

---

# WP_Block_List::key(): int|null

## In this article

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

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

Returns the key of the current element of the block list.

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

 int|null Key of the current element.

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

    ```php
    #[ReturnTypeWillChange]
    public function key() {
    	return key( $this->blocks );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-block-list.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-wp-block-list.php#L169)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-block-list.php#L169-L172)

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

| Used by | Description | 
| [WP_Block_List::current()](https://developer.wordpress.org/reference/classes/wp_block_list/current/)`wp-includes/class-wp-block-list.php` |

Returns the current element of the block list.

  |

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

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

## User Contributed Notes

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