unregister_taxonomy

函数
unregister_taxonomy ( $taxonomy )
参数
  • (string) $taxonomy Taxonomy name.
    Required:
返回值
  • (true|WP_Error) True on success, WP_Error on failure or if the taxonomy doesn't exist.
定义位置
相关方法
register_taxonomyunregister_meta_keyis_taxonomyget_taxonomyunregister_setting
引入
4.5.0
弃用
-

unregister_taxonomy: 在WordPress中取消注册一个先前注册的分类法: 这个函数从已注册的分类法列表中删除该分类法,并从数据库中删除所有相关术语。

取消注册一个分类法。

不能用于取消注册内置分类法。

function unregister_taxonomy( $taxonomy ) {
	if ( ! taxonomy_exists( $taxonomy ) ) {
		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
	}

	$taxonomy_object = get_taxonomy( $taxonomy );

	// Do not allow unregistering internal taxonomies.
	if ( $taxonomy_object->_builtin ) {
		return new WP_Error( 'invalid_taxonomy', __( 'Unregistering a built-in taxonomy is not allowed.' ) );
	}

	global $wp_taxonomies;

	$taxonomy_object->remove_rewrite_rules();
	$taxonomy_object->remove_hooks();

	// Remove the taxonomy.
	unset( $wp_taxonomies[ $taxonomy ] );

	/**
	 * Fires after a taxonomy is unregistered.
	 *
	 * @since 4.5.0
	 *
	 * @param string $taxonomy Taxonomy name.
	 */
	do_action( 'unregistered_taxonomy', $taxonomy );

	return true;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-16 03:35:16

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: