Home Forums Add-ons User Submitted ACF Country field


ACF Country field

  • Hi,

    I needed a country field for a project I’m working on so I quickly developped an addon for this :

    This addon displays an ISO 3166-1 alpha 2 country list. Country names are available in every language and probably in your WordPress installation language.

    This plugin requires :
    – ACF v4+
    – PHP 5.3.3+

    Beware, the weight of this plugin is about 10mo.

    I plan to improve a little bit this plugin later for greater compatibility (ACF 3, etc.).

    Hope it will help someone else !

    • Elliot

    • January 7, 2014 at 10:17 am

    Hi @nlemoine

    Great work!


    • Rneeson

    • November 17, 2014 at 1:10 pm

    I just downloaded the file and installed it all went good but when i went to insert the
    into the php file it came up with an error and wont let me insert it?
    where do i insert it into the file sorry for being so stupid please see your code below thanks in advance

    Plugin Name: Advanced Custom Fields: Country Field
    Plugin URI:
    Description: Adds a country as well as city/state field to your WordPress sites.
    Version: 1.0.0
    Author: Dwayne Charrington
    Author URI:
    License: GPL

    class acf_field_country_plugin

    public function __construct()
    $domain = “acf-country-field”;
    $mofile = trailingslashit(dirname(__File__)) . ‘lang/’ . $domain . ‘-‘ . get_locale() . ‘.mo’;
    load_textdomain( $domain, $mofile );

    add_action(‘acf/register_fields’, array($this, ‘register_fields’));

    register_activation_hook( __FILE__, array($this, ‘populate_db’) );
    register_deactivation_hook( __FILE__, array($this, ‘depopulate_db’) );

    public function register_fields()
    include_once ‘register-fields.php’;

    public function populate_db()
    require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’);

    require_once “lib/install-data.php”;
    $sql = ob_get_clean();
    dbDelta( $sql );

    public function depopulate_db()
    require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’);

    require_once “lib/drop-tables.php”;
    $sql = ob_get_clean();
    dbDelta( $sql );


    new acf_field_country_plugin();

  • Hello,

    You’re adressing your issue to the wrong plugin. Check the Github URL in the first post.

  • Hi there,
    This is just what I needed. However, will this also work with ACF Pro?

    edit: Unfortunately it doesn’t work with ACF Pro

  • Unfortunately I can confirm that. When activating the plugin, an error occurs.

    Fatal error: Cannot redeclare composerRequire …

    It’s a pitty, this one would have been handy for me just now.

  • For this plugin:
    I have add ACF field to woocommerce product. Countries field is visible, country chosing works properly, but when save produkt and page reload country list looks like default view. Should display selected country. Not save selected country.

  • Hi,

    I just updated the plugin, it’s been improved and is now fully functionnal with ACF 4 & 5 (pro).

    You can check it here:

  • Hi,

    Works great on my site!

    Just a suggestion if you can add states for each country chosen.
    The 1st option to choose is country. Once country is chosen, only states from that chosen country appear for 2nd option.


  • Hi,

    Sorry, this field aims to only display countries.

    Adding states would also involve some issues.
    States are a US administrative concept, they are called “lander” in Germany, “region” which has a subdivision called “departement”. At a world scale, it would be quite hard to handle every country specificities.

    If you want state option, you can install the other ACF country plugin:

    • Spen

    • November 2, 2017 at 9:13 am

    Great plugin @nlemoine – the country flags are not loading inside the select, though. Any idea? All of the assets appear to be loading correctly.

    Cheers 🙂

    • Beee

    • November 5, 2017 at 3:44 am

    Nice feature with the flags.

    For those of you that might be looking for a more extensive location selection, I’ve just released v0.1 of the ACF City Selector plugin where you can select a country, the a state (within that country) and then a city (within that state).

    Read more about it on

  • Wow, that looks impressive, Berry. I definitely keep an eye on this!

  • @nlemoine I want to show value of country was chosen from back-end to front-end

    i was using this code

    get_field(‘country_selling’); // country_selling are field name when setup

    but it show value NULL

    can you guide me how to show value of country was chosen.


Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.