sharing video on facebook from wordpress

That really depends on how the video is embedded into the page. Facebook can only handle specific formats and if it sees something it doesn’t expect, it defaults to a failsafe “show nothing” standard. If the embedded video is well-recognized standard (i.e. YouTube’s default player) it should work just fine. If it’s your own self-hosted … Read more

Generating the ogp tags in theme

If it is a page the global post object is already set when wp_head fires. But you have to get the data for this page with custom code. Pseudo code: add_action ( ‘wp_head’, ‘wpse_58539_get_ogp’ ); function wpse_58539_get_ogp() { if ( ! is_page_template( ‘your-template-name’ ) ) { return; } $page = get_post( $GLOBALS[‘post’] ); // Inspect … Read more

custom field with total count of Facebook likes, comments and shares

I’ve done it, here is the complete code: function insert_facebook_likes_custom_field($post_ID) { global $wpdb; if (!wp_is_post_revision($post_ID)) { add_post_meta($post_ID, ‘likes_count’, ‘0’, true); } } add_action(‘publish_page’, ‘insert_facebook_likes_custom_field’); add_action(‘publish_post’, ‘insert_facebook_likes_custom_field’); function update_facebook_likes($content=””) { global $wp_query; $permalink = get_permalink(); $idpost = $wp_query->post->ID; $data = file_get_contents(‘http://graph.facebook.com/?id=’.$permalink); $json = $data; $obj = json_decode($json); $like_no = $obj->{‘shares’}; $meta_values = get_post_meta($idpost, ‘likes_count’, true); if … Read more