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 :
1
function rb_weglot_localise_oembed_url($html) {
2
$search = '/wp-json/oembed';
3
$current_language = weglot_get_current_language();
4
$default_language = weglot_get_original_language();
5
if ($current_language !== $default_language) {
6
$html = str_replace($search, "/$current_language/wp-json/oembed", $html);
7
}
8
return $html;
9
}
10
add_filter('weglot_html_treat_page', 'rb_weglot_localise_oembed_url');
Copied!
Once done, you can check the preview on LinkedIn using https://www.linkedin.com/post-inspector/
Last modified 3mo ago
Copy link