Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress 4: WPLANG deprecated. How to change language programmatically?

Since WPLANG is deprecated in Wordpress 4, what do you use to set a user selected language? In versions 3.x.x I used define('WPLANG', $lang) to set a language and then on the pages could get it using get_locale(). I need to use this approach to differentiate the content for the different languages. I know that it's possible to change the language in Settings->General but I need to do that programmatically.

Thanks

like image 961
Alex Avatar asked Oct 17 '25 15:10

Alex


1 Answers

With WordPress 4.0 the define WPLANG from wp-config.php is - as you have mentioned - depreciated. It has been replaced by an option called WPLANG stored in the table <TablePrefix>_options.

You could use get_option() to access it:

$my = get_option('WPLANG','en_US');

More details about the change can be found here.

like image 51
Bjoern Avatar answered Oct 19 '25 05:10

Bjoern



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!