Title: extract_serialized_parent_block
Published: November 13, 2024
Last modified: February 24, 2026

---

# extract_serialized_parent_block( string $serialized_block ): string

## In this article

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

[ Back to top](https://developer.wordpress.org/reference/functions/extract_serialized_parent_block/?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.

Accepts the serialized markup of a block and its inner blocks, and returns serialized
markup of the wrapper block.

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

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

 * [remove_serialized_parent_block()](https://developer.wordpress.org/reference/functions/remove_serialized_parent_block/)

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

 `$serialized_block`stringrequired

The serialized markup of a block and its inner blocks.

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

 string The serialized markup of the wrapper block.

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

    ```php
    function extract_serialized_parent_block( $serialized_block ) {
    	$start = strpos( $serialized_block, '-->' ) + strlen( '-->' );
    	$end   = strrpos( $serialized_block, '<!--' );
    	return substr( $serialized_block, 0, $start ) . substr( $serialized_block, $end );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/blocks.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/blocks.php#L1335)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/blocks.php#L1335-L1339)

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

| Used by | Description | 
| [inject_ignored_hooked_blocks_metadata_attributes()](https://developer.wordpress.org/reference/functions/inject_ignored_hooked_blocks_metadata_attributes/)`wp-includes/block-template-utils.php` |

Inject ignoredHookedBlocks metadata attributes into a template or template part.

  |

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