woocommerce/docs/code-snippets/rename-a-country.md

24 lines
831 B
Markdown
Raw Normal View History

2023-11-29 18:48:05 +00:00
---
post_title: Rename a country
tags: code-snippet
2023-11-29 18:48:05 +00:00
---
2023-08-22 12:36:43 +00:00
Add this 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](https://wordpress.org/plugins/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.
2023-08-22 12:36:43 +00:00
```php
if ( ! function_exists( 'YOUR_PREFIX_rename_country' ) ) {
/**
* Rename a country
*
* @param array $countries Existing country names
* @return array $countries Updated country name(s)
*/
function YOUR_PREFIX_rename_country( $countries ) {
2023-08-23 10:48:03 +00:00
$countries['IE'] = __( 'Ireland (Changed)', 'YOUR-TEXTDOMAIN' );
2023-08-22 12:36:43 +00:00
return $countries;
}
add_filter( 'woocommerce_countries', 'YOUR_PREFIX_rename_country' );
}
```