Adding WP Post Excerpts to Facebook Links
Here’s a little bit of web geekery for you… I want to share links on Facebook, but every time I do that I get the same link info no matter what blog post I’m linking to. How do I change that? The answer’s below the fold…
When you add a link to your Facebook entries (like Wall posts or Page posts), it pulls that page’s Meta Description and adds it to the link. The problem is that, by default, WordPress uses your blog’s main description for its Meta Description on every single page. So this is what I get:

It does this because my theme’s Header has a Meta Description tag that looks like this:
<meta name='description' content='This is the official site for Matthew Ebel, the fastest-growing independent piano-rock musician from Boston.'>
So how do you get a concise excerpt to show up in Facebook? Change that Meta Description tag to look like this:
<meta name='description' content='<?php
if ( is_single() ) {
the_excerpt_rss();
} else { ?>
THIS IS WHERE YOU'D TYPE IN WHAT YOU WANT TO DISPLAY OTHERWISE.
<?php } ?>'>
Once that's in place, you get this:

For more information on the WordPress the_excerpt_rss() tag, read their documentation here.
Update: Chris Penn noted that this means you have to give up your existing Meta Description on your blog posts. Not so! Placement is everything. If you just want to add the excerpt to the existing tag, try this...
<meta name='description' content='THIS IS WHERE YOU'D TYPE IN WHAT YOU WANT TO DISPLAY OTHERWISE.<?php
if ( is_single() ) {
echo ' - ';
the_excerpt_rss();
} ?>'>
You can also limit the number of words in the excerpt if you want to keep it short and to the point. Read the WP documentation for details.
P.S.: If you liked what you read, please share it with others!




Pingback: Adding Wordpress Excerpts to Google+ Posts | Matthew Ebel