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
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
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:
<?php $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!