Using the Open Graph Protocol, Vimeo, and WordPress
Advertise on Across the Wire
Here’s a quick and easy way to implement the Open Graph Protocol in WordPress to share your Vimeo videos on Facebook. First, add the below code to the header.php file of your theme and change the og:site_name to match the name of your website.
<?php if ( get_post_meta($post->ID, 'vimeo', true) ) : ?> <meta property="og:url" content="<?php the_permalink() ?>" > <meta property="og:title" content="<?php the_title(); ?>" > <meta property="og:description" content="<?php echo get_post_meta($post->ID, 'description', true) ?>" > <meta property="og:type" content="video" /> <meta property="og:image" content="<?php echo get_post_meta($post->ID, 'image', true) ?>" /> <meta property="og:video" content="http://vimeo.com/moogaloop.swf?clip_id=<?php echo get_post_meta($post->ID, 'vimeo', true) ?>" /> <meta property="og:video:secure_url" content="https://vimeo.com/moogaloop.swf?clip_id=<?php echo get_post_meta($post->ID, 'vimeo', true) ?>" /> <meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:video:width" content="640" /> <meta property="og:video:height" content="360" /> <meta property="og:site_name" content="Across the Wire" /> <?php endif; ?>
Next, add three new Custom Fields called vimeo, image, and description. Add the video location of the video (ie. 22213718), the location of the image you’d like to use, and a brief description you’d like to use for your post. You may have to activate these two functions. The Screen Options pull down tab is located in the upper right corner of your Dashboard. If they are not listed, you will have to add support manually by editing your functions.php file.
'supports' => array('title', 'editor', 'thumbnail', 'comments', 'revisions', 'excerpt', 'custom-fields')
Warning: This is only an example. Please use extreme caution when editing your functions.php file.




