WP_Block_Templates_Registry::unregister( string $template_name ): WP_Block_Template|WP_Error

In this article

Unregisters a template.

Parameters

$template_namestringrequired
Template name including namespace.

Return

WP_Block_Template|WP_Error The unregistered template on success, or WP_Error on failure.

Source

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;
}

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.