Set Twitter language for WordPress oEmbeds

The oEmbed tweets on my hosted blog have been coming up in Chinese for the last few months, and I’ve been unable to resolve the situation with my web host. Add this to your theme’s functions.php if you are having the same issue; it will check the WP_LANG setting in wp-config.php and update the request to Twitter accordingly.

The filter that allows this functionality was added in WordPress 3.5.

2 thoughts on “Set Twitter language for WordPress oEmbeds

  1. Alex Mills

    To more effectively target just Twitter embeds, I’d use parse_url(). Something like this:

    if ( 'twitter.com' == parse_url( $url, PHP_URL_HOST ) ) {

    Then you don’t also match the rare but possible case where “twitter.com” is elsewhere in the URL.

    Reply

Leave a Reply