Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have an English blog. In one of the pages I want to include a Hebrew paragraph between two English paragraphs (I expect the English text to be left-aligned and the Hebrew text to be right-aligned). I can get the Hebrew text to be right aligned, but not in a right-to-left way (e.g. the period at the end of the sentence appears to it's right instead of its left).

I tried pasting formatted text from Microsoft Word, but it doesn't work (the pasted text changes from right-to-left as it was in Word to the screwed-up form I get on WordPress if I type it myself).

I do not want the admin interface to change, I do not want my entire blog to change to right-to-left. Only a paragraph.

How can I achieve that? The site is http://roee.co

share|improve this question

1 Answer 1

up vote 9 down vote accepted

You can add a hebrew shortcode to wrap around your hebrew text and then use the CSS2 direction attribute to indicate the text direction.

e.g.:

In your themes functions.php:

function hebrew_shortcode( $atts, $content = null ) {
   return '<p lang="he" DIR="RTL">' . $content . '</p>';
}
add_shortcode( 'hebrew', 'hebrew_shortcode' );

Your content:

[hebrew]Hebrew styled right to left text![/hebrew]

edit: I've updated to use the dir html attribute ( spec docs said do nto sue css to indicate right to left ) and to use a p element instead

share|improve this answer
    
Please excuse my lack of experience, but could you please elaborate on where exactly I should paste these two snippets? Thanks! –  Roee Adler Apr 9 '12 at 18:23
1  
The CSS goes in your css file ( style.css ) and the PHP goes in you functions.php file in your theme –  Tom J Nowell Apr 9 '12 at 18:45
    
I pasted both code snippets in the css file and the functions.php file (both were pasted at the end of the relevant file), but it doesn't work, the text [hebrew]בדיקה.[/hebrew] still has the "." to the right of the word instead of to it's left in the published page. The page I'm playing with is here: roee.co/%D7%A8%D7%95%D7%A2%D7%99-%D7%90%D7%93%D7%9C%D7%A8 thanks –  Roee Adler Apr 9 '12 at 18:59
    
I do not see the <span> tags present as necessary in the frontend markup –  Tom J Nowell Apr 9 '12 at 19:10
3  
To be semantically correct, I'd recommend using the attribute/value pair 'lang="he"' to the P tag. In fact, you could omit the class attribute entirely and use the lang attribute for any CSS matching. So if you wanted to style the Hebrew text specially, you'd add a rule with the selector p[lang="he"] to your CSS. –  Adam Rice Apr 9 '12 at 23:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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