Đã hoàn thành

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.

Kĩ năng: WordPress, PHP

Xem nhiều hơn: 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

Về Bên Thuê:
( 204 nhận xét ) San Francisco, United States

ID dự án: #22417699

Được trao cho:

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 Thêm

$10 USD trong 1 ngày
(3 Đánh Giá)
2.2

5 freelancer đang chào giá trung bình $22 cho công việc này

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] Thêm

$30 USD trong 1 ngày
(6 Nhận xét)
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 Thêm

$20 USD trong 7 ngày
(1 Nhận xét)
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 Thêm

$20 USD trong 1 ngày
(7 Nhận xét)
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 Thêm

$30 USD trong 3 ngày
(0 Nhận xét)
0.0