Suoritettu

Fix Wordpress Rewrite per language

I'm using this code to rewrite URLs as per language (from here: [login to view URL]):

I do not want the session rules so I excluded them:

function lang_support() {

return array('en','fr'); // Add your support lang-code (1st place is a default)

}

function rewrite_lang(){

$langs = lang_support();

foreach($langs as $lang) {

add_rewrite_endpoint($lang,EP_PERMALINK|EP_PAGES|EP_ROOT|EP_CATEGORIES);

}

}

add_action('init','rewrite_lang');

function lang(){

global $wp_query;

$langs = lang_support();

$lang_r = "";

foreach($langs as $lang) {

if(isset($wp_query->query_vars[$lang])) {

$lang_r = $lang;

$_SESSION['lang'] = $lang_r;

}

}

if(in_array($lang_r,$langs)) {

return $lang_r;

} else {

return $langs[0];

}

}

It works just fine for 'en' and 'fr' but when I add more languages (i.e. 'es' and 'it' to the array it fails and brings up a random post.

Please install on your Wordpress and find out what's wrong.

Taidot: WordPress, PHP

Näytä lisää: fix wordpress php problems, fix wordpress theme corruption, fix wordpress blog, fix wordpress post count, fix wordpress post html problem, fix wordpress feed, fix wordpress database corrupt, build dual language website turn languages, fix wordpress blog freelancer, fix wordpress changing hosts, fix wordpress script, display post fix wordpress, wordpress rewrite apache work, fix wordpress widgets, fix wordpress php script, wordpress rewrite hack

Tietoa työnantajasta:
( 204 arvostelua ) San Francisco, United States

Projektin tunnus: #22417699

Myönnetty käyttäjälle:

josephman1988

Hey! This seems to be an easy enough request! I'm very well versed in debugging a multitude of bugs / issues caused by plugins / inefficient code. I have a lot of experience in wordpress so please take a look at Lisää

$10 USD 1 päivässä
(3 Arvostelua)
2.2

5 freelanceria on tarjonnut keskimäärin 22$ tähän työhön

BluetechAsia

Hi!! I hope you are doing well!! I have gone through your project requirements. Sure, I will fix your issues as per your needs. I developed many websites you can check my previous work: [login to view URL] Lisää

$30 USD 1 päivässä
(6 arvostelua)
4.4
fsdsolutions1

Hi I have reviewed your requirements for your preconceived project As all your requirements are crystal clear to me so, I would like to discuss your project querries in more detail which would let me to quote you t Lisää

$20 USD 7 päivässä
(1 arvostelu)
3.3
VHK0

Hello, As a talented WordPress expert, I have been working in WordPress for 6+ years and have all the skills WordPress. I feel fit for your project and you will be satisfied with my working. I would like to work on you Lisää

$20 USD 1 päivässä
(7 arvostelua)
2.8
digitalech

Hello, We have a team of Professional USA Based expert developers & Designers, who are always ready to work on the inspired and creative needs of the client. Please have a chat with me so that I may be able to further Lisää

$30 USD 3 päivässä
(0 arvostelua)
0.0