questions

How can we differentiate between translated and orignal post in wpml?

Rate this post

I am making a custom author.php file in wordpress and showing post there but thing is it is also showing translated data too, like my web is in Enligsh and it is translated in Chinese how can i specify the between post which one is English which is Chinese.

i’m using it

$courses = get_posts([
                "post_type" => "lp_course",
                "numberposts" => "-1",
                "author" => $guru->ID
            ]);
            echo '<pre>';
            print_r($courses);
            echo '</pre>';

 

✔️Solution:

To return only posts for the current language you need set ‘suppress_filters’ of the get_posts function to false.

$courses = get_posts([
    "post_type" => "lp_course",
    "numberposts" => "-1",
    "author" => $guru->ID,
    "suppress_filters" => false
]);

Leave a Reply

Your email address will not be published.

Back to top button