开发者

Wordpress, change language_attributes to return dir=rtl

开发者 https://www.devze.com 2023-01-20 01:40 出处:网络
In wordpress, inside the header.php file of a theme, there is the next line: <html xmlns=\"http://www.w3.org/1999/xhtml\" <?php language_attributes(); ?>>

In wordpress, inside the header.php file of a theme, there is the next line:

<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>

By default, it(language_attributes) returns dir=ltr, and every online guide i read tr开发者_开发技巧ied to show a way to hange the css file.

it's not enough and not semantic. i need to change the html itself to rtl. how can it be done? is there a settings file?


You can control the text direction via the language files. If you download the Arabic(an RTL langauge) Wordpress for example. You'll find this value is set in the \wp-content\languages\ar.php as:

$text_direction = 'rtl';

And to enable it..you need to set the WPLANG variable in your wp-config to the RTL language like this:

define ('WPLANG', 'ar');

Then your language_attributes() will output the dir='rtl' you want.


The best way to edit your default language is through the wp-config.php file on the root directory.

This case should be for Spanish of Spain define ('WPLANG', 'es_ES');

This one to the USA English define ('WPLANG', 'en_US');

You have all the possible combinations at this page: http://xml.coverpages.org/iso639a.html

Regards


Take a look at the following two links. You need to ensure both of your theme and WordPress are setup for RTL.

http://codex.wordpress.org/Right_to_Left_Language_Support

http://codex.wordpress.org/Function_Reference/get_bloginfo

0

精彩评论

暂无评论...
验证码 换一张
取 消