New! – Get the brand new version MultilingualPress 3.2

How to get connected post IDs by current post ID

To get an array of connected posts you can use the translationIds function. That method is the equivalent of mlp_get_linked_elements in MultilingualPress 2:

The first parameter is the source post id, the second is the post type and the third parameter is the source site id:

$translations = \Inpsyde\MultilingualPress\translationIds(1, 'post', 1);

it will return an array of key value pairs as site id and post id:

array (size=2)

1 => int 1

2 => int 1

You can loop through $translations like this:

if($translations) {

   foreach($translations as $siteId => $postId) {
      echo 'Site ID: ' . $siteId . ' Post ID: ' . $postId . '<br>';
   }
}

Build the perfect multilingual webshop with WooCommerce and our plugins MultilingualPress and OneStock!