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. To more effectively target just Twitter embeds, I’d use parse_url(). Something like this:

    if ( '' == parse_url( $url, PHP_URL_HOST ) ) {

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

Leave a Reply