J
J
Jekil2015-05-04 18:15:02
Internationalization and localization
Jekil, 2015-05-04 18:15:02

How to switch the theme on wordpress when changing the language?

Good afternoon!
I ask for help and tips. There is a simple blog, with its own simple template.
I want to make it multilingual, I used the qtranslate x plugin to switch articles to ru/en. It works great.
But there was a problem in the template on the pictures of the background, caps and various buttons, I have text in Russian. I decided to make a copy of the template, redrawn the text on the pictures, respectively, into English.
Now I have two templates ru and en
. But I don't know how to make it so that when you click on the corresponding language flag, not only the language of the articles, but also the template is switched.
In my search, I didn’t find anything worthwhile =(
Unfortunately, in WordPress, as well as in php, I don’t understand almost anything at all.
In his search, the current came to a piece of code:

<?php if(get_locale() == 'ru_RU') { ?>
здесь повидимому должна быть какая-то переключалка на мойшаблон_ru
 <?php } else if(get_locale() == 'en_EN') { ?>
 а здесь соответственно переключалка на мойшаблон_en
 <?php } ?>

Please tell me some solution to my problem.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Kamenev, 2015-05-04
@Jekil

In the function.php of the current theme:

function change_theme() {
  if(get_locale() == 'ru_RU')
    $theme = 'twentytwelve';
  else
    $theme = 'twentyteleven';
  return $theme;
}

add_filter('template', 'fxn_change_theme');
add_filter('option_template', 'fxn_change_theme');
add_filter('option_stylesheet', 'fxn_change_theme');

But it's better to change only the style sheet (the last line).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question