The theme I am using has a function to embed videos from Facebook. The problem is that whenever I use it it loads the SDK in uk_UA for whatever reasons (Ukrainian).

Nothing related to my Website or Facebook is using this language. After contacting the theme developers i was told it's not their fault and might be something related to the server configuration.

I tried an hacky solution I found here with adding to the funcitons.php the following script

add_filter( 'the_content', 'facebook_sdk_replace' );
function facebook_sdk_replace( $content ) { if ( is_single() ) { $content = str_replace("/uk_UA/", "/en_US/", $content); } return $content; }

As it had no effect, the developer suggested I should add to the _header_php the following

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.6";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

The problem I am facing is that by doing so, I am getting the following error:

Cannot modify header information - headers already sent by...

Therefore, I reverted back my header.php. Is there a way to fix this issue without altering the header?

Later edit: The only code snippet I found is the following:

        /* $buffy = '
        <div class="wpb_video_wrapper td-facebook-video">
            <iframe src="' . td_global::$http_or_https . '://www.facebook.com/plugins/video.php?href=' . urlencode($videoUrl) . '&show_text=0" width="' . $width . '" height="' . $height . '" scrolling="no" frameborder="0" allowTransparency="true" allowFullScreen="true" ></iframe>

         * cache & oembed implementation
        $cache_key = self::get_facebook_id($videoUrl);
        $group = 'td_facebook_video';

        if (td_remote_cache::is_expired($group, $cache_key) === true) {

            // cache is expired - do a request
            $facebook_api_json = td_remote_http::get_page('https://www.facebook.com/plugins/video/oembed.json/?url=' . urlencode($videoUrl) , __CLASS__);

            if ($facebook_api_json !== false) {
                $facebook_api = @json_decode($facebook_api_json);

                //json data decode
                if ($facebook_api === null and json_last_error() !== JSON_ERROR_NONE) {
                    td_log::log(__FILE__, __FUNCTION__, 'json decode failed for facebook video embed api', $videoUrl);

                if (is_object($facebook_api) and !empty($facebook_api->html)) {

                    //add the html to the buffer
                    $buffy = '<div class="wpb_video_wrapper">' . $facebook_api->html . '</div>';

                    //set the cache
                    td_remote_cache::set($group, $cache_key, $facebook_api->html, self::$caching_time);

            } else {
                td_log::log(__FILE__, __FUNCTION__, 'facebook api html data cannot be retrieved/json request failed', $videoUrl);

        } else {
            // cache is valid
            $api_html_embed_data = td_remote_cache::get($group, $cache_key);
            $buffy = '<div class="wpb_video_wrapper">' . $api_html_embed_data . '</div>';
  • It's not wordpress related question I suppose. Can you open source page of your site and find place where connect.facebook contains? We will try to suggest where you should make changes then – Anton Lukin Aug 23 '17 at 17:48
  • Cannot modify header information - headers already sent by... error occurs if anything is added before headers sent using php's header function. Even a blank line or space will give this error. – inarilo Aug 23 '17 at 20:32
  • @AntonLukin how can I ... open source a page ? I'd gladly do that. For now, here's an example: esportsmedia.ro/highlights/pubg/pan-power – Erythros Aug 24 '17 at 7:18

I've found your problem.

You've inserted video from facebook on your page with facebook init script.

Take a look at language options

Find the place where you insert this video and change uk_UA to en_US there.

  • That's what I was trying to say. That's not being done manually in the theme files, but more like being pulled from an API or something. I tried searching for that one line in the entire server (in each file). Nothing came up – Erythros Aug 25 '17 at 6:28
  • I added a code snippet of where the magic is happening. Nothing else came by when searching for connect.facebook – Erythros Aug 25 '17 at 6:36
  • Try to find it in database. Select * from wp_posts where post_content like '%connect.faceboook%'; – Anton Lukin Aug 25 '17 at 9:13
  • there's nothing like that in wp_posts. I tried to find a solution all this time. but nada – Erythros Oct 4 '17 at 21:21

The reason for this issue was given on the wordpress core ticketing system.

This is probably something you should report to Facebook (good luck), as WordPress is correctly outputting the lang attribute on the html element. Facebook likely uses heuristics to determine if the actual page language is indeed English or not when en_US is used, similar to what Google Chrome does. This is the unfortunate situation that the web finds itself in when services cannot trust web standards due to incorrect implementations (ie. sites not in US English but still using en_US as the lang). In your situation you may be able to make use of the og:locale OpenGraph tag to persuade Facebook that your content really is in US English.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.