• Resolved Daniel Zimmermann

    (@optimiertes)


    First, thanks for writing this great plugin!

    Is there PHP-Code to find out if the current Page/Post has already a translated version in a certain language?

    Thanks,
    Dan

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

    (@takayukister)

    bogo_get_post_translations() returns an array of translations for given post/page.

    $translations = bogo_get_post_translations( $post_id );

    This $translations is an array, and its keys are locale codes like en_US, de_DE, and ja. So, for example, if you want to check if the post has a de_DE translation, check if there is a key ‘de_DE’ in the array, like this:

    $translations = bogo_get_post_translations( $post_id );
    
    if ( isset( $translations['de_DE'] ) ) {
    	$translated_post = $translations['de_DE'];
    } else {
    	// You don't have a translation.
    }

    At this time the $translated_post (if it exists) is a post object.

    Thread Starter Daniel Zimmermann

    (@optimiertes)

    Thanks a lot Takayuki, it worked fine!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Check if Page/Post has a translated equivalent in a certain language’ is closed to new replies.