hellonico / acf-country
A country field for ACF.
Fund package maintenance!
Open Collective
Installs: 82 018
Dependents: 0
Suggesters: 0
Security: 0
Stars: 117
Watchers: 8
Forks: 17
Open Issues: 11
Type:wordpress-plugin
Requires
- php: ^7.4 || ^8.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.42
- symplify/easy-coding-standard: ^12.1
- umpirsky/country-list: *
- wpengine/advanced-custom-fields-pro: ^6.0
README
Adds a 'Country' field type for the Advanced Custom Fields WordPress plugin.
⚠️ WARNING ⚠️
From version 2.0.0, ACF Country introduced some important breaking changes:
- Dropped support for older PHP & ACF versions, new requirements are:
- ACF 5.7+
- PHP 5.4+
- Return format has changed. To better stick to ACF and make use of ACF functions, ACF Country will now return values the same way select field do.
['FR' => 'France']
will now look like['label' => 'France', 'value' => 'FR']
Looking for a ACF pre 5.7 support? Check the 1.0 branch.
Overview
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:
Compatibility
- ACF 5.7+
- PHP 5.4+
Field options
Filters
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
Installation
Zip
Download the plugin and extract the archive to your plugins folder.
Composer
composer require hellonico/acf-country
Contributing
See CONTRIBUTING.
Support
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.