admin管理员组文章数量:1122846
I'm working on a website that needs to be RTL, after reading some articles online I understood that in order for the website to be RTL I need to change the site language to a RTL language.
Through this path: Settings >> General >> Site Language
Did that and it changed the website to RTL but it changed all the website's content (front-end and admin panel) to the RTL language.
Can I change only the front-end part to RTL without changing my admin panel's language?
Thanks.
I'm working on a website that needs to be RTL, after reading some articles online I understood that in order for the website to be RTL I need to change the site language to a RTL language.
Through this path: Settings >> General >> Site Language
Did that and it changed the website to RTL but it changed all the website's content (front-end and admin panel) to the RTL language.
Can I change only the front-end part to RTL without changing my admin panel's language?
Thanks.
Share Improve this question asked Feb 7, 2018 at 18:53 TonyTony 211 silver badge2 bronze badges 3- tu use differents languages in frontend and backend, you can use a plugin like Polylang : wordpress.org/plugins/polylang – mmm Commented Feb 7, 2018 at 18:57
- check this, here exactly answered wptavern.com/… – Abdul Aziz Commented Dec 21, 2019 at 7:34
- I had this exact problem and almost went for a multilingual plugin just to solve it. What eventually solved it for me is to set the global site language to be Arabic (settings -> general), and then going to my user (in users) and setting my preferred language to English. – Ghadir Commented Dec 4, 2021 at 2:18
2 Answers
Reset to default 0Set your WordPress to a RTL language, then use the following code in functions.php
or as the plugin:
<?php
add_filter( 'locale', 'my_set_admin_locale' );
function my_set_admin_locale( $locale ) {
// check if you are in the Admin area
if( is_admin() ) {
// set LTR locale
$locale = 'en_US';
}
return( $locale );
}
Or otherwise, set WordPress to LTR and set front-end to RTL:
if( ! is_admin() ) { // not admin area
// set RTL locale
$locale = 'ar';
}
Like so :
add_filter('locale', function ($locale) {
global $wp_locale;
if (isset($_COOKIE['farsi'])) {
$wp_locale->text_direction = 'rtl';
return 'fa_IR';
} else {
$wp_locale->text_direction = 'ltr';
return 'en_US';
}
});
本文标签: How to make the frontend RTL without changing the admin panel language
版权声明:本文标题:How to make the front-end RTL without changing the admin panel language? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736288267a1928059.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论