skip to Main Content
< All Articles
Print

rem_states

This filter can be used to add/modify the states of a country.

Arguments

  1. States Data [Array]

Add/Modify States

Add code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Avoid adding custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme.

Note: You must replace both instances of XX with your country code. This means each state id in the array must have your two-letter country code before the number you assign to the state.

add_filter( 'rem_states', 'custom_rem_states' );

function custom_rem_states( $states ) {

  $states['XX'] = array(
    'XX1' => 'State 1', 
    'XX2' => 'State 2'
  );

  return $states;
}

Example

The following snippet will add Portugal states.

add_filter( 'rem_states', 'custom_rem_states' );

function custom_rem_states( $states ) {

  $states['PT'] = array(
    'PT-01' => 'Alentejo', 
    'PT-02' => 'Algarve',
    'PT-03' => 'Beira',
    'PT-04' => 'Douro Litoral',
    'PT-05' => 'Minho',
    'PT-06' => 'Ribatejo',
  );

  return $states;
}
Quick Navigation
Back To Top