Title: WP_Block_Patterns_Registry::prepare_content
Published: November 8, 2023
Last modified: September 10, 2024

---

# WP_Block_Patterns_Registry::prepare_content( array $pattern, array $hooked_blocks ): string

## In this article

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

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

Prepares the content of a block pattern. If hooked blocks are registered, they get
injected into the pattern, when they met the defined criteria.

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

 `$pattern`arrayrequired

Registered pattern properties.

`$hooked_blocks`arrayrequired

The list of hooked blocks.

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

 string The content of the block pattern.

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

    ```php
    	if ( $outside_init_only ) {
    		$patterns = &$this->registered_patterns_outside_init;
    	} else {
    		$patterns = &$this->registered_patterns;
    	}
    	if ( ! isset( $patterns[ $pattern_name ]['content'] ) && isset( $patterns[ $pattern_name ]['filePath'] ) ) {
    		ob_start();
    		include $patterns[ $pattern_name ]['filePath'];
    		$patterns[ $pattern_name ]['content'] = ob_get_clean();
    		unset( $patterns[ $pattern_name ]['filePath'] );
    	}
    	return $patterns[ $pattern_name ]['content'];
    }
    ```

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

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

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