How to get the latest entry in the selected language using qTranslate-x?

Settings in settings => languages ​​for "Hide content inaccessible to the selected language". not marked . This is the preferred state for the entire site, but for some posts I would like to show only the last message in the selected language. (Thus, with no default behavior: "Sorry, this entry is only available in French.").

So far I have this code that shows the last message in the language in which it is written, but I would like to receive only messages written in the selected language.

while ( have_posts() ) : the_post();
$mypost = get_post(get_the_ID()); 
$content = qtranxf_use('en', $mypost->post_content,false); 
echo "$content";
endwhile;
+4
source share
1 answer

, :

$mypost = array('post_type' => 'posts', 'paged' => get_query_var('paged'), 's' => '[:en]',  'posts_per_page' => 7);

query : [: en] , . :

$loop = new WP_Query($mypost);
while ($loop->have_posts()) : $loop->the_post(); ?>

    <article>
        <?php the_content(); ?>
    </article>
<?php
endwhile;
+1

All Articles