WordPress.org

Forums

Bogo
[resolved] Check if Page/Post has a translated equivalent in a certain language (3 posts)

  1. Daniel Zimmermann
    Member
    Posted 1 year ago #

    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

  2. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. Daniel Zimmermann
    Member
    Posted 1 year ago #

    Thanks a lot Takayuki, it worked fine!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Bogo
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.