WP_Block_List::offsetGet() WordPress Method

The WP_Block_List::offsetGet() method is used to retrieve a block from the list by its index. This is useful when you need to loop through all the blocks in a post and perform an action on each one.

WP_Block_List::offsetGet( $index ) #


Source

File: wp-includes/class-wp-block-list.php

	public function offsetGet( $index ) {
		$block = $this->blocks[ $index ];

		if ( isset( $block ) && is_array( $block ) ) {
			$block                  = new WP_Block( $block, $this->available_context, $this->registry );
			$this->blocks[ $index ] = $block;
		}

		return $block;
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.