LinkedIn Share Post: Translate oEmbed WP URL

Use filter to translate oEmbed WP URL

Data used by LinkedIn is not being fetched from the page title attribute but from the WP oEmbed data to be rendered in the LinkedIn preview.

With the filter below you can translate the oEmbed url :

function rb_weglot_localise_oembed_url($html) {
   $search = '/wp-json/oembed';
   $current_language = weglot_get_current_language();
   $default_language = weglot_get_original_language();
   if ($current_language !== $default_language) {
      $html = str_replace($search, "/$current_language/wp-json/oembed", $html);
   return $html;
add_filter('weglot_html_treat_page', 'rb_weglot_localise_oembed_url');

Once done, you can check the preview on LinkedIn using

Last updated