WordPress Post featured image URL in the header

To answer this one and point to the real problem: As the <head> HTML tag comes far before the actual loop, you’ll need something else than the global $post. get_queried_object(); get_queried_object_id(); The plugin The code is tested and works. As you might want to keep this functionality when switching themes, I’d suggest wrapping it up … Read more

How do I create a page for users to invite their facebook friends?

An easy way would be to include the Facebook Javascript code: wp_deregister_script(‘facebook’); wp_enqueue_script( ‘facebook’, ‘https://connect.facebook.net/en_US/all.js’ ); Then use the default Facebook invite page. <script> function facebookInvite(){ var request = { message: ‘my message’, method: ‘apprequests’ }; FB.ui(request, function (data) { if (data.request_ids.length > 0) { alert(“Facebook invite successful.”); } }); } </script> EDIT: Here are … Read more

Conditionally loading Facebook PHP SDK in shortcode

You can try to use the_posts filter to search for you shortcode and require the sdk, something like this: function has_my_FB_shortcode($posts) { if ( empty($posts) ) return $posts; $found = false; foreach ($posts as $post) { if ( stripos($post->post_content, ‘[my_shortcode’) ){ $found = true; break; } } if ($found) require(‘path/to/facebook_sdk.php’); return $posts; } add_action(‘the_posts’, ‘has_my_FB_shortcode’);