Multilingual theme: Changing locale based on URL

My problem here is that get_query_var(‘language’) isn’t defined in the function set_my_locale Because get_locale (which applies the filter locale) is called before wp() (which parses the query & sets up the variables). You’ll have to manually inspect the request yourself: if ( strpos( $_SERVER[‘REQUEST_URI’], ‘/de/’ ) === 0 ) { // German } else { … Read more

How to change language file used by _e function

Actually you need to hook in the ‘locale’ filter to set the language you want: add_filter(‘locale’, function($locale) { return esc_attr($_GET[‘language’]); }); Then in the links of your switch, you need to pass the language variable: <a href=”https://wordpress.stackexchange.com/questions/260015/<?php echo add_query_arg(“language’, ‘xx_XX’) ?>”>XX</a> Where xx_XX is the language locale code for language XX

How to change menu according to the language?

This can be done via cookies. We set it with Javascript, reload the page and display different menus in PHP using its value. First, print the script at the site footer (see comments). Note: would be better to enqueue this together with your theme scripts. add_action( ‘wp_footer’, ‘wpse_77220_language_cookie’ ); /** * Cookie script based on … Read more

Custom Meta Field not Working with qTranslate [closed]

Less complicated is to use the plugin’s Quicktags and use the Gettext functions to print the content in the site. [:en]English[:pt]Português Quicktags docs Another option is to do just like qTranslate interface does with the post titles: Create one custom field for each language in your meta box: qTrans documentation is not consolidated, so analyzing … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)