Snippets: Different Body Font Family for Different Languages

The typography options in the Total theme are all saved as arrays as WordPress "theme mods" these can be easily hooked into if you want to conditionally change them. Here is an example showing how you can hook into the global theme options array to change the body font-family for different languages.

add_action( 'after_setup_theme', function() {

	// Get global Customizer settings
	global $wpex_theme_mods;

	// Check for body font family setting
	if ( isset( $wpex_theme_mods['body_typography']['font-family'] ) ) {

		// Get current language
		$current_language = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : '';

		// Change body font-family for Spanish language code "es"
		if ( 'es' == $current_language ) {
			$wpex_theme_mods['body_typography']['font-family'] = 'Lobster';
		}

	}

}, 40 );
All PHP snippets should be added via a child theme's functions.php file.