WordPress qtranslate display post of some language

For example I have 2 languages: EN and RU: how to display in index.php post only in RU language ? maybe are some parameters in wp_query ?

Related posts

Leave a Reply

2 comments

  1. Try to use qtranslate core function

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

    Something like this:

    $mypost = get_post(get_the_ID()); 
    $content = qtrans_use('ru', $mypost->post_content,false); 
    echo "$content";
    
  2. In new versions of qtranslate and qtranslate-x will work only as follows:

    $postId = get_the_ID();
    
    wp_cache_delete($postId, 'posts');
    $mypost = WP_Post::get_instance($postId);
    
    $titleEn = qtrans_use('en', $mypost->post_title, false);
    $titleRu = qtrans_use('ru', $mypost->post_title, false);
    //or all object:
    $mypost = qtrans_use('en', $mypost, false);
    

    See more about it (rus): https://intsystem.org/coding/qtranslate-x-vyvod-stati-v-drugom-yazyke/