<html lang="ja-jp" dir="ltr"><head></head><body>### [国際住所スキームにおける英国の都道府県フィールドのカスタマイズ](https://wpforms.com/developers/customizing-the-state-field-for-the-united-kingdom-in-the-international-address-scheme/)

**公開日:** 2026年4月20日
**著者:** Umair Majeed

**コンテンツ:**

住所フィールドで英国が選択されたときに、都道府県/地域フィールドの動作をカスタマイズしたいですか？国際スキームを使用する場合、英国は伝統的な意味での州を使用しないため、WPFormsはデフォルトで英国の都道府県/地域フィールドを非表示にします。代わりに、国（イングランド、スコットランド、ウェールズ、または北アイルランド）や郡などの値を収集したい場合は、カスタムコードスニペットでそれを行うことができます。

このチュートリアルでは、英国の都道府県/地域フィールドを再度有効にし、ラベルを変更し、テキスト入力を英国の国のドロップダウンに置き換える方法を説明します。

---

## スニペットの作成

始める前に、[カスタムコードスニペットをサイトに追加する方法](https://wpforms.com/developers/how-to-add-custom-php-or-javascript-for-wpforms/#using-wpcode-plugin-recommended)に関するチュートリアルを確認してください。

このスニペットは2つのことを行います。まず、都道府県/地域フィールドを非表示にする国のリストから英国を削除します。次に、フロントエンドに少量のJavaScriptを追加して、フィールドのラベルを更新し、ユーザーが英国を選択したときにテキスト入力をドロップダウンに置き換えます。

次に、次のスニペットをサイトに追加してください。

```

/**
 * 国際スキームで英国が選択されたときに住所フィールドの都道府県/地域入力をカスタマイズします。
 *
 * @link https://wpforms.com/developers/customizing-the-state-field-for-the-united-kingdom-in-the-international-address-scheme
 */

add_filter( 'wpforms_forms_fields_address_frontend_strings_list_countries_without_states', 'wpf_forms_fields_address_frontend_strings_list_countries_without_states' );

function wpf_forms_fields_address_frontend_strings_list_countries_without_states( $countries ) {

	return array_diff( $countries, [ 'GB' ] );
}

add_action( 'wpforms_frontend_js', 'wpf_forms_fields_address_frontend_great_britain_countries_list' );
function wpf_forms_fields_address_frontend_great_britain_countries_list( $forms) {
	$load = false;

	foreach ( $forms as $form ) {
		if ( wpforms_has_field_type( 'address', $form ) ) {
			$load = true;

			break;
		}
	}

	if ( ! $load ) {
		return;
	}

	?&gt;

**カテゴリ:** チュートリアル, フィールド

---</body></html>