# unregister_post_type()

URL: https://chugunov.pro/api-wordpress/functions/unregister_post_type/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 4.5.0.

## Сигнатура

```php
unregister_post_type( string $post_type ): true|WP_Error
```

## Описание

Нельзя использовать для отмены регистрации встроенных типов записей.

## Параметры

- `$post_type` `string` — обязательный. Тип записи, регистрацию которого нужно отменить.

## Возвращаемое значение

`true|WP_Error` — WP_Error

## Исходный код

Файл: `wp-includes/post.php:1886`

```php
function unregister_post_type( $post_type ) {
	global $wp_post_types;

	if ( ! post_type_exists( $post_type ) ) {
		return new WP_Error( 'invalid_post_type', __( 'Invalid post type.' ) );
	}

	$post_type_object = get_post_type_object( $post_type );

	// Do not allow unregistering internal post types.
	if ( $post_type_object->_builtin ) {
		return new WP_Error( 'invalid_post_type', __( 'Unregistering a built-in post type is not allowed' ) );
	}

	$post_type_object->remove_supports();
	$post_type_object->remove_rewrite_rules();
	$post_type_object->unregister_meta_boxes();
	$post_type_object->remove_hooks();
	$post_type_object->unregister_taxonomies();

	unset( $wp_post_types[ $post_type ] );

	/**
	 * Fires after a post type was unregistered.
	 *
	 * @since 4.5.0
	 *
	 * @param string $post_type Post type key.
	 */
	do_action( 'unregistered_post_type', $post_type );

	return true;
}
```

## История изменений

- 4.5.0 — Introduced.

## Связанные

Использует: [`post_type_exists`](https://chugunov.pro/api-wordpress/functions/post_type_exists/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`do_action`](https://chugunov.pro/api-wordpress/functions/do_action/), [`get_post_type_object`](https://chugunov.pro/api-wordpress/functions/get_post_type_object/), `WP_Error::__construct`.

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/unregister_post_type/
