How do you get the content by id and by specific language?

I need to display two specific language content in a page, regardless of the session's language. So far, this is my progress: this works fine for getting the content by id of the active language:

<?php $id=47; $post = get_page($id); $content = apply_filters('the_content', $post->post_content); echo $content;  ?>

How to apply a specific language to the filter?

Thanks for the help. Sziro


1 Answer 1


You must use the qTranslate native functions to do your job. Use qtrans_use, that is the function that do all the job in qTranslate. It's defined in qtranslate_core.php, line 747

function qtrans_use($lang, $text, $show_available=false) 

Use it on the raw content of the post!

Try this code:

 $id=47; $post = get_page($id); 
 $content = qtrans_use('en', $post->post_content,false); 
 echo $content;  

In this example, it will return the English version of your text! Substitute it with the desired language identifier to translate into another language!

  • Yes, glad to have helped you!
    – keatch
    Commented May 12, 2012 at 14:58
  • This works perfectly, but it took me a few attempts to realise that the get_page($id) bit is important. By the time you're rendering the view, qTranslate has already modified the contents of $post to only contain the current language, so you need to load it again to get the options for all languages. Commented Jul 26, 2012 at 12:57
  • @keatch can you help me with this plugin it keep on showing english text always, I have installed it properly, do i need to make any other changes in code? or it will work normally without doing anything
    – Jack
    Commented Sep 10, 2012 at 10:31
  • If you still need help you can contact me personally or ask here. I'd be glad to help out. @Jack
    – Lenin
    Commented Jan 19, 2013 at 16:54
  • 1
    @ShivanRaptor to get the current language identifier you can use many ways but most recommended is: qtrans_getLanguage().
    – Lenin
    Commented Oct 20, 2013 at 10:45

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