WpCode.net

Daily Wordpress Code Snippet

How to add new Facebook “Send Button” to your WordPress Theme

| 0 comments

Pin It

On April, 25 facebook add into their social plugin the new “Send” button. The difference between “I Like” and “Send” button is that with the like button you publish a link on your wall, with the Send Button you will be able to send a private message to a specific contact, friend or email address.

To a better facebook experience you may add the open graph tag. Continue reading

Add Send Button Via Plugin:

I wrote a plugin called Facebook Send for WordPress that allow you to add the send button on your theme.

Add Send button Via Code:

Open your function.php and:

Add the Open Graph tag:

function wpc_fbmetatag() {
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');

?>

<!-- START Facebook Open Graph meta tag-->

<meta property="og:title" content="<?php the_title(); ?>" />
<meta property="og:url" content="<?php the_permalink(); ?>" />
<meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
<meta property="og:description" content="<?php the_title(); ?>" />
<meta property="fb:app_id" content="<?php echo get_option('wpc_fcw_appid'); ?>">
<meta property="fb:admins" content="<?php echo get_option('wpc_fcw_adminid'); ?>"/>
<meta property="og:image" content="<?php echo $large_image_url[0] ?>"/>

<!-- END Facebook Open Graph meta tag-->
<?php }

add_action('wp_head', 'wpc_fbmetatag');

And now add the button:

function wpc_fb_sendbutton() { ?>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=INSERT APP ID HERE&amp;xfbml=1"></script><fb:send href="<?php the_permalink(); ?>" font=""></fb:send>
<?PHP } ?>

And Now wherever you want in your theme:

<?php if ( function_exists('wpc_fb_sendbutton()')) {wpc_fb_sendbutton} ?>

Leave a Reply

Required fields are marked *.

*