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

---

# WP_Block_Templates_Registry::unregister( string $template_name ): 󠀁[WP_Block_Template](https://developer.wordpress.org/reference/classes/wp_block_template/)󠁿|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

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

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

Unregisters a template.

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

 `$template_name`stringrequired

Template name including namespace.

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

 [WP_Block_Template](https://developer.wordpress.org/reference/classes/wp_block_template/)
|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) The unregistered
template on success, or [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
on failure.

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

    ```php
    public function unregister( $template_name ) {
    	if ( ! $this->is_registered( $template_name ) ) {
    		/* translators: %s: Template name. */
    		$error_message = sprintf( __( 'Template "%s" is not registered.' ), $template_name );

    		_doing_it_wrong( __METHOD__, $error_message, '6.7.0' );

    		return new WP_Error( 'template_not_registered', $error_message );
    	}

    	$unregistered_template = $this->registered_templates[ $template_name ];
    	unset( $this->registered_templates[ $template_name ] );

    	return $unregistered_template;
    }
    ```

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

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

| Uses | Description | 
| [WP_Block_Templates_Registry::is_registered()](https://developer.wordpress.org/reference/classes/wp_block_templates_registry/is_registered/)`wp-includes/class-wp-block-templates-registry.php` |

Checks if a template is registered.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [_doing_it_wrong()](https://developer.wordpress.org/reference/functions/_doing_it_wrong/)`wp-includes/functions.php` |

Marks something as being incorrectly called.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_block_templates_registry/unregister/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_block_templates_registry/unregister/?output_format=md#)

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