Stars: 109
Forks: 14
Pull Requests: 12
Issues: 38
Watchers: 6
Last Updated: 2022-11-21 21:15:40
ACF Country field - Display a select field of all countries, in any language.
License:
Languages: PHP, JavaScript, SCSS
Adds a 'Country' field type for the Advanced Custom Fields WordPress plugin.
From version 2.0.0, ACF Country introduced some important breaking changes:
['FR' => 'France'] will now look like ['label' => 'France', 'value' => 'FR']Looking for a ACF pre 5.7 support? Check the 1.0 branch.
Display a select list of all countries in your language.
Country names are available in every language (see available list). By default, country names are localized in your current WordPress language.
Select a single value:
Or multiple ones:
| Option | Default | Description |
|---|---|---|
| Default value | emtpy | Set a default value for the country field (as country code) |
| Allow null | false |
Enable/disable null value |
| Allow multiple | false |
Enable/disable multiple countries selection |
| Stylised UI | true |
Enable/disable enhanced select field thanks to Select2 |
| Return format | value |
See ACF Select field |
You can remove (or add) some countries with the acf/country/countries filter, example:
add_filter( 'acf/country/countries', function( $countries ) {
return array_filter( $countries, function( $code ) {
return !in_array( $code, ['IC', 'EA'], true );
}, ARRAY_FILTER_USE_KEY);
} );Note: PHP5.6+ example
Download the plugin and extract the archive to your plugins folder.
composer require hellonico/acf-countrySee CONTRIBUTING.
This ACF field was originally developed for a personal project I don't use anymore. I still decided to maintain it anyway. If you use it in a commercial project, please consider buying me a beer.