When adding new languages to your site using TranslatePress, you can choose to display the language flag of each language in your language switcher. Here’s how to replace the default image for each flag and change flags in TranslatePress.
If you’re looking to replace the default flags for certain languages of your multilingual site you can use one of the two options below:
You can add a new flag for an existing language directly from TranslatePress Settings → Advanced tab → Custom Language section.
From here you can modify all the information about an existing language, or just use another image for the flag.
Once you’ve uploaded and selected the new flag image make sure to click Save Changes.
You can read more about Custom Languages here.
Note: if you are looking to replace the default flags in order to add a custom language please consult the documentation here.
You can replace the default flags in TranslatePress by using a bit of coding:
/** * Change flags folder path for certain languages. * * Add the language codes you wish to replace in the list below. * Make sure you place your desired flags in a folder called "flags" next to this file. * Make sure the file names for the flags are identical with the ones in the original folder located at 'plugins/translatepress/assets/images/flags/'. * If you wish to change the file names, use filter trp_flag_file_name . * */ add_filter( 'trp_flags_path', 'trpc_flags_path', 10, 2 ); function trpc_flags_path( $original_flags_path, $language_code ){ // only change the folder path for the following languages: $languages_with_custom_flags = array( 'en_US', 'es_ES' ); if ( in_array( $language_code, $languages_with_custom_flags ) ) { return plugin_dir_url( __FILE__ ) . '/flags/' ; }else{ return $original_flags_path; } }