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

---

# WP_Block_List::offsetSet( int $offset, array|WP_Block $value )

## In this article

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

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

Assign a block value by the specified block offset.

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

 `$offset`intrequired

Offset of block value to set.

`$value`array|[WP_Block](https://developer.wordpress.org/reference/classes/wp_block/)
required

Block value.

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

    ```php
    #[ReturnTypeWillChange]
    public function offsetSet( $offset, $value ) {
    	if ( is_null( $offset ) ) {
    		$this->blocks[] = $value;
    	} else {
    		$this->blocks[ $offset ] = $value;
    	}
    }
    ```

[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#L111)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-block-list.php#L111-L118)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_block_list/offsetset/?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%2Foffsetset%2F)
before being able to contribute a note or feedback.