0

I have this piece of code that get a post with the same name of my "item description". I need my post to be translated dynamically with qtranslate but it only gets the WHOLE post content...so in few words I see both english and other language. Anyone with a good solution?

<?php $content_post = get_page_by_path( $item->item_description, OBJECT, 'post' );
if($content_post)
{
$content = $content_post->post_content;
echo $content;
}?>

I'm not goot with php so please try to be "clear" with your answers. Thank you very much!

Bruno Ferraro
  • 55
  • 1
  • 5

1 Answers1

1

I found this solution, it works but im not sure if it's a fairly good code:

if($content_post)
{
if(qtrans_getLanguage() == "it"){
$content = qtrans_use('it', $content_post->post_content,false); 
echo $content;
}else{
$content = qtrans_use('en', $content_post->post_content,false); 
echo $content;
}
}?>
Bruno Ferraro
  • 55
  • 1
  • 5