PHP code example of hellonico / acf-country

1. Go to this page and download the library: Download hellonico/acf-country library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hellonico / acf-country example snippets


$events = new WP_Query([
    'post_type' => 'event',
    'meta_query' => [['key' => 'country', 'value' => 'FR']],
]);

use function n5s\AcfCountry\get_countries;
use function n5s\AcfCountry\get_country_flag;
use function n5s\AcfCountry\get_country_name;

get_countries();             // ['AF' => 'Afghanistan', ...], in the site language
get_countries('fr_FR');      // [..., 'ZA' => 'Afrique du Sud', ...]
get_country_name('DE');      // 'Germany', null for an unknown code
get_country_flag('FR');      // '🇫🇷', '' when the code is not two letters

add_filter('acf/country/countries', static function (array $countries): array {
    unset($countries['IC'], $countries['EA']);

    return $countries;
});