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:
Facebook Fail
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:
Facebook Win

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!

  • Aaron Cooper

    Playing Drive Away on The FourTunes Podcast 2moro Matthew http://fourtunes.mevio.com

  • Aaron Cooper

    Playing Drive Away on The FourTunes Podcast 2moro Matthew http://fourtunes.mevio.com

  • Walt Ebel

    Huh??

    Dad

  • Walt Ebel

    Huh??

    Dad

    • http://matthewebel.com Matthew Ebel

      Total geek stuff here, unless you plan on marketing a blog sometime soon. ;)

  • http://matthewebel.com Matthew Ebel

    Total geek stuff here, unless you plan on marketing a blog sometime soon. ;)

  • wintress

    I had the same problem, but this coding was just too hard for me. I finally figured out that if you aren't very good at the coding, you can just upload a plug in. The All in One SEO pack seems to be the popular one, and it will automatically write unique META tags per page (or you can write your own). We use it on our blog…you can see the results here: http://www.thewritersforhire.com/blog.

  • wintress

    Oh, I should mention that probably only works for WordPress blogs.

  • Anonymous

    I had the same problem, but this coding was just too hard for me. I finally figured out that if you aren’t very good at the coding, you can just upload a plug in. The All in One SEO pack seems to be the popular one, and it will automatically write unique META tags per page (or you can write your own). We use it on our blog…you can see the results here: http://www.thewritersforhire.com/blog.

  • Anonymous

    Oh, I should mention that probably only works for WordPress blogs.

  • wintress

    I had the same problem, but this coding was just too hard for me. I finally figured out that if you aren't very good at the coding, you can just upload a plug in. The All in One SEO pack seems to be the popular one, and it will automatically write unique META tags per page (or you can write your own). We use it on our blog…you can see the results here: http://www.thewritersforhire.com/blog.

  • wintress

    Oh, I should mention that probably only works for WordPress blogs.

  • http://www.usa-basketball-shoes.com Kobe Bryant Shoes

    Nike Zoom LeBron James Soldier
    The idea of friends upstairs is new and original,but I think to buy XX in the professinal outlet store is to our profit because things there have high quality &low price.When we are not rich,it can help us save 50-70% money there,why not buy them there?

  • http://www.chaneloutletstores.com/Chanel-accessories.html Chanel accessories

    Well , the view of the passage is totally correct ,your details is really reasonable and you guy give us valuable informative post, I totally agree the standpoint of upstairs. I often surfing on this forum when I m free and I find there are so much good information we can learn in this forum!
    Chanel shoes

  • Marius Suiu

    Hello there! I think your method would be really useful, but for some reason, when I recommend some article, on my Facebook wall will appear my related posts. I have installed All in one SEO, and the problem still persists.

    Could you please help me? Thank you!

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