0

I have a question. I am working on a WordPress theme, which is in English and Russian. My question is how do I change my "header" and footer depending on the URL. I have a logo, which is in Russian (Cyrillic) and in English (Latin). I would like it to show the the English version when URL contains /en and Russian (Cyrillic) when URL contains /ru.

I assume that I will be able to use the same code to change the footer which should include latinic letters when URL contains /en and Cyrillic when URL includes /ru.

I have been browsing the web for a while now and I came close to some answers but to be honest I am not an expert in coding (in any language). For instance:

$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];

if (false !== strpos($url,'car')) {
     echo 'Car exists.'; } else {
     echo 'No cars.'; }

I have no idea why $url doesn't work. I assume it has something to do with jQuery... No idea really.

I suppose it should be something like... If URL contains /en then use this header, footer, else use Russian...

Perhaps there exists a plug in or something that could solve my problem, but I can't find anything useful.

Any help is much appreciated.

  • no offense intended, but if you are not expert in coding how can you make a theme? – Mark Kaplun Dec 22 '13 at 11:25
  • No offense taken =) the default WordPress themes have a lot .php files with hundreds of lines of code. Its practically impossible for a person like me to make heads or tales of it. I know something about coding but just the basics, so I decided to make a simple theme myself... I followed a few tutorials checked the codex etc. but this kind of things are just beyond me at the moment. – Luka Dec 22 '13 at 21:01
  • the problem is that your question is not really related to wodpress but to general php programing which is just off-topic here. you should just read the documentation about the $_SERVER variable and try to debug by echoing value until you understand what going on. But in general your total approch is wrong, the best way to handle multi langs is to have two different sites or use special okugins for that, you are trying to reinvent the wheel in what you do right now. – Mark Kaplun Dec 23 '13 at 4:14
  • I'll check it out. Otherwise I'll just make 2 sites... that was always the "last resort" plan. Thanks. – Luka Dec 23 '13 at 16:18
1

I worked out the answer.

<?php $url = $_SERVER["REQUEST_URI"];
        if (strpos($url, "/ru/"))  {
               ;
        }else {
               ;
              } ?> 

Figured out that I don't actualy need to change the whole footer but just the content. =) Can be closed now. Cheers

|improve this answer|||||
  • Click the check mark to mark the answer that solved your problem as The Solution. – fuxia Dec 28 '13 at 19:21
  • nothing on this particular page helped me... like i mentioned I browsed the forum and internet and somehow amidst all those answers I somehow composed the working code... – Luka Jan 5 '14 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.