Skip to content

Instantly share code, notes, and snippets.

@zalog
Created January 30, 2018 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zalog/7aafc5e49d008b917501c23e63308f71 to your computer and use it in GitHub Desktop.
Save zalog/7aafc5e49d008b917501c23e63308f71 to your computer and use it in GitHub Desktop.
wordpress: change language for theme only
<?php
// load default translated strings based on locale
load_default_textdomain();
// theme translated strings, modify as you need
load_theme_textdomain( 'zatheme', get_template_directory() . '/languages' );
<?php
/**
* Plugin Name: plugin
* Description: plugin custom
* Version: 1.0.0
*/
// prevent direct access
defined('ABSPATH') or die();
add_filter('locale', 'zatheme_locale');
function zatheme_locale($locale) {
if ( !is_admin() ) {
// modify as you need
$locale = 'en_US';
}
return $locale;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment