Home Forums Responsive Themes Auction Theme City/State missing location Reply To: City/State missing location

  • JamesD
    Super Guru 1,722 points
    April 25, 2019 at 7:10 am

    I don’t believe there’s anything built-in to do this.

    If you’re comfortable working with code then Ithismight be able to help you get started. This function will allow you to add additional city/states to the current list of states and re-alphabetize them.

    Note: Make sure you change the new states accordingly. This will update the global variable that holds the states. Be sure to test it thoroughly as well.

    function custom_states_init() {
        if( isset($GLOBALS['core_state_list'])) {
            // Get all CORE pre-set states
            $aStates = $GLOBALS['core_state_list'];
            // Set the City/State by 2 character country code IN CAPS.
            $aStatesAdd = array(
                // 'GB' is the country code for the United Kingdom
                'GB' =>
                    array( 'A First New United Kingdom State',
                         'A Second New United Kingdom State'
                // 'US' is the country code for the USA
                'US' =>
                    array( 'A First New USA State',
                         'A Second New USA State'
            if(!isset($aStatesAdd) || empty($aStatesAdd)) { return; }
            foreach ($aStatesAdd as $key=>$val) {
                if(is_array($val)) {
                    $str = $aStates[$key];
                    $str .= '|' . implode('|', $val);
                    $aTmp = explode('|', $str);
                    // Sort new arrays
                    // Update state with new values
                    $aStates[$key] = implode('|', $aTmp);
            // Change state values with new data
            $GLOBALS['core_state_list'] = $aStates;
    add_action('init', 'custom_states_init');
  • New Business Themes for WordPress 2020

    Start your new website today!

    View Business Themes