• Resolved craig21

    (@craig21)


    Hi there,

    Is it possible to detect if a page or post has been translated?
    I am only looking to output the shortcode if a translated page exists.

    Thanks for the great plugin!

    Thanks,

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Use bogo_get_post_translation( $post_id, $locale ) this returns false if there is no translation for the page of $post_id in $locale.

    Thread Starter craig21

    (@craig21)

    Thank you!

    Would this work then?

    if (bogo_get_post_translation($post_ID, ‘zh-CN’)) {
    // Do something
    }

    Or do I need to pass in the post from the global $post?

    Thanks again!

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    The $locale should be 'zh_CN', or you can also use bogo_get_closest_locale( 'zh-CN' ). If the $post_ID has a valid post ID integer value, it’s ok, not necessary to be the global $post variable.

    Thread Starter craig21

    (@craig21)

    Thanks for the clarification! Works great!

    Cheers!

    Hello Takayuki Miyoshi. I would like to extend this question.

    bogo_get_post_translation() = returns true or false whether or not the post has translations.

    Is there another function to get an array of the post’s translations?

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Detect if a page has a translation’ is closed to new replies.