WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to load the facebook php sdk in the wordpress template. I've added the code to the header.php file:

    locate_template( 'facebook/facebook.php', true );

$facebook = new Facebook(array(
     'appId'  => appid,
     'secret' => appsecret

$signedRequest = $facebook->getSignedRequest();

if ( isset($signedRequest['app_data']) )
    echo $signedRequest['app_data'];    

But I get get this error:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent..

How can I load the facebook sdk before any other file is loaded

share|improve this question

You shouldn't add functionality to themes. Or even worse: To templates. Wrap it up in a plugin and load the plugins bootstrap on plugins_loaded, or - in case of a mu-plugin - on muplugins_loaded.

In every case, you shouldn't throw around with globals. Just add your output to a custom filter or hook and only add this one to your template: (Example) do_action( 'facebook_app_data' );

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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