Jul
2nd

WordPress: Dynamic Meta Description on each Post

Thanks for stopping by my personal blog on Marketing Technology! Over 50,000 visitors a month find my content worth returning for, so don't forget to subscribe to the Marketing Technology Blog RSS feed or to the Marketing Technology Email to have new content sent directly to your inbox. You may also find my other business blog helpful, Social Media Domination.

Your default WordPress header defines a single description of any page of your site, regardless of the page that someone landed on from a search engine. That the description in the search engine may not actually describe the post that is in the blog may result in less people clicking on your link.

I never thought about this until this weekend when I received the following review of my site by BlogStorm:

Nice, an easy one to link bait! Try adding some social bookmarking buttons on the bottom of your posts and some unique meta descriptions on each page.

Monetizing a blog like this is hard, if you try everything John Chow has tried then you will be on the right track.

With some imagination and a lot of link baiting you will be able to get enough links to rank for some really good terms (maybe you do already). Once you rank for these terms you can stick affiliate links and Adsense on the pages and reap the profits.

Getting your site reviewed is a fantastic thing because it will often identify some issue with your site that you’re not paying attention to. In this case, it’s my meta tag description for each of my posts. Meta descriptions are utilized by search engines to apply a brief description of the page listed in the results. Since people will see different pages when they search for you, why not apply different meta descriptions for each of your pages?

I already modified my header to include dynamic keywords for my keyword meta tag and it has helped improved the rankings of some of my posts. Applying different descriptions may not increase my search positioning, but as BlogStorm points out - it could lead to more interaction with my pages from the results of folks searching.

Description of the Solution

If the page in my site is a single page, such as when you click on a single post, you want an excerpt of the page. I want the excerpt to be the first 20 to 25 words of the post but I need to filter our any HTML whatsoever. Luckily, WordPress has a function that will provide me with that I need, the_excerpt_rss. Though it wasn’t meant for this use, it’s an ingenious way to apply the word limit and strip out all HTML elements!

I might even take this a step further and utilize the Optional Excerpt within WordPress to populate the meta description, but for right now this is a nice tidy shortcut! (If you use this approach AND enter an Optional Excerpt, it will utilize that excerpt for the Meta Description).

The Header Code

This function requires that you call it within The Loop, so there’s some complexity to it:

<meta name=”description” content=”<?php if (have_posts()&& is_single()):while(have_posts()):the_post(); the_excerpt_rss(20,2); endwhile; else: ?>My default description<?php endif; ?>” />

NOTE: Be sure to replace “My default description” with whatever you currently have or would like as your blog’s meta description.

What this code does is provides the default meta description for your blog anywhere but on a Single Post page, in which case it takes the first 20 words and strips out all the HTML from it. I’m going to continue to fine tune the code (removing linefeeds) and incorporating an ‘if statement’ if there is an Optional Excerpt. Stay tuned!

RSS feed | Trackback URI

10 Comments »

Comment by no imageStephen (SezWho)
2007-07-02 16:16:22

This is awesome Doug. Thanks for sharing!
Rate this:
2.9
 
Comment by no imagePhil (SezWho)
2007-07-02 17:10:54

Nice one Doug, I look forward to seeing this progress. Mine is a bit of a botch job at the moment (I think), so I’m kind of glad to see someone else doing the hard work!
Rate this:
2.9
 
Comment by no imageDouglas Karr (SezWho)
2007-07-02 20:25:21

One note - I updated the post since I thought you had to do some logic if someone utilized the “Optional Excerpt” on the post. However, you don’t have to - the Optional Excerpt will automatically be displayed if it’s utilized… another nice feature of the_excerpt and the_excerpt_rss functions.
Rate this:
2.9
Comment by no imageSatria Anandita (SezWho)
2007-07-03 07:10:22

Hahaha…! You really mean to beat John Chow, don’t you? ^^ Nice!
Rate this:
2.9
Comment by no imageDouglas Karr (SezWho)
2007-07-03 07:30:38

Making over $10k per month on my blog would be quite nice! However, John (a ‘virtual friend’ and person I have incredible respect for) invests a lot in paying for attention. He’s recently gotten into trouble by Google and Technorati - these could hurt him quite a bit with his revenue in the future.

But I am appreciative that guys like him have the cahonies to push the limit - John lets guys like me know where the line is!

:)

Rate this:
2.9
 
 
 
2007-07-03 19:43:50

[...] WordPress: Dynamic Meta Description on each Post | The Marketing Technology Blog Dynamic Meta Description on each Post (tags: wordpressmods) [...]
 
Comment by no imageDouglas Karr (SezWho)
2007-07-03 23:15:07

Just a follow-up, I did find the All in One SEO Pack WordPress Plugin that will do this for you!

I’ll be pulling some of my code this week and implementing this plugin instead to keep things clean. NOTE: Found on John Chow’s Blog.

Rate this:
2.9
 
2007-07-04 10:53:44

[...] written two different posts on developing your site’s meta tags, keywords and descriptions. Keywords will definitely assist in your site’s findability, but descriptions will help [...]
 
Comment by no imageKanwal (SezWho)
2007-07-04 11:32:37

How about including the category names and the blog name for each post…. does this improve on the SEO factors? I think so!


cat_name . ','; };the_excerpt_rss(20,2); endwhile; else: ?> - " />

Rate this:
2.8
 
Comment by no imagerod (SezWho)
2008-06-17 14:53:11

FYI:
If you’re running YAPB as your image solution, this code will pull your lead image into the meta and display it above the body when viewing the front end.
Rate this:
1.6
 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

My Comment Policy: I moderate comments. Please be patient:

  • Spam will happily be destroyed.
  • Use your real name, not some keywords. Otherwise it will be destroyed.
  • Mean comments aren't necessary. If I don't post them I will reply personally to let you know why.
  • Lewd comments will be edited, I don't want my readers leaving because of offensive content.
Great debate, criticism and colorful commentary is always appreciated and approved!