0

I want to create two single.php templates, one for English language and the other one for Persian language, because post in English is too different according the post in Persian, because of the css direction need.

For this propose I've created two single.php templates, but everytime the English one opens.

Now, how do I send the post to the other one which is Persian single.php.

4
  • I'm not familiar with Persian, is it written from right-to-left Commented Aug 13, 2014 at 6:28
  • Yeah of course just like Urdu or Arabic or Kurdish... Commented Aug 13, 2014 at 6:30
  • The best approach would be the use of a multilingual plugin like WPML (it's a premium plugin) or Polylang or something similar that fits your requirements. See the codex for further info : codex.wordpress.org/Multilingual_WordPress Commented Aug 13, 2014 at 6:32
  • sorry I didn't mention in my Post of course already I used qTranslate plugin yeah it's working so awesome but my design have to change , ltr to rtl in , so do you have an Idea about this ? Commented Aug 13, 2014 at 6:34

2 Answers 2

1

I think you have to make two categories first. Sorry my English is very bad, if my answer is a little bit understandable (:D).

Create 3 files for the single page: single.php, singleEnglish.php, singlePersian.php, then add this code in single.php:

<?php
$post = $wp_query->post;
if (in_category('tag_id Persian') ) {include(TEMPLATEPATH . '/singlePersian.php');}
else {include(TEMPLATEPATH . '/singleEnglish.php');
}?>

Example can be found here. Single page is different for Products and Blog.

Sign up to request clarification or add additional context in comments.

2 Comments

tag_ID filled with number:1,2,3 bla bla.. persian category id your category, sorry if to much information :D
[email protected] please contact with me send to me an Email
0

You can't run two single.php for the same post type. The template hierarchy doesn't allow that.

You need to look into rtl support for your site. It is extensively covered in the codex. You can also have a look at the bundled themes to get a basic idea of how to do this.

The other means might be is to use get_locale() to split you single.php

Example: (Please note, I'm using Afrikaans as the locale to check, change this to Persian)

if( 'af_AF' == get_locale()){

   // Do something for Afrikaans language

}else{

   // Do something else for other languages

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.