This is part of my series of Learning Microformats.
As you might notice, I’ve created a Sponsored Links block (still work in progress). The original markup was actually only to display my sponsors link with some short description using dl tag. Then I had this idea, Why not I marked up it with Microformats hReview
.
Taking advantage of WordPress Bookmarks
When you create a link or bookmark from WordPress admin panel there are several field that you can fill in besides URI, Name and Description. The extended Add Bookmark option would allow you to add Link Relationship (XFN) and Rating which is perfect to complete hReview specification.
The code
So I created a custom loop instead of using the standard get_links_list() function to fetch all the Bookmarks. The code look something like this:
<ol>
<?php $links = $wpdb->get_results("SELECT link_url, link_name, link_description, link_rating, link_rel, link_image FROM $wpdb->links"); foreach ($links as $link) { ?>
<li class="hreview">
<a class="item url fn" href="<?php echo $link->link_url; ?>" title="Visit <?php echo $link->link_name; ?>"><?php echo $link->link_name; ?></a>
<span>Rating: <span class="rating"><?php echo $link->link_rating; ?></span></span>
<p class="summary">
<?php echo $link->link_description; ?>
</p>
</li>
<?php } ?>
</ol>
Note: To add XFN relationship simply use $link->link_rel. To add a photo use $link->link_image.
By following hReview schemas, I came up with:
- item info: Represent by
$link->link_url,$link->link_name. - rating: Represent by
$link->link_rating. - summary or description: Represent by
$link->link_description.
Why not xfolk?
My sponsors block consists of link, rating and a summary but not description. Ability to show items rating is a bonus which xfolk not supported.
Moreover, I’d plan to link each item from the Sponsored Link block to a separate full review page which I plan to write (using a complete hReview schemas) soon.
Nice, eh?
So there you have it folks. Finally, I found some good use of the WordPress Bookmarks. Furthermore, if you like to define your own markup to display WordPress Bookmarks, you could reuse the code above. There’s probably mistake somewhere, not to mention room for improvement.
Also see Ryan King’s hReview Creator and Tails Export by Robert de Bruin.
Hrm… so in essence you’re putting the advertisements on your site in hreview format? Doesn’t having aggregated reviews of advertisements on your site sound a bit shady?
Am I completely missing what you’re saying here Zeo? People are misusing the hreview format all over the place, mostly on purpose to attract people to their ads and affiliate links with minimal effort. I know that’s not what you’re proposing here, but I’m not quite sure why you’d be using hreview other than the semantic similarities.
What about XOXO or the related listings format?
You want me to start working on building microformat support/formatting into K2? There are plugins like the Structured Blogging one (bleh) but it’d be much better to have native styling and support, no? Just a thought. I believe a lot of microformats (particularly hreview) are going to be a trainwreck, but then, I always liked watching trainwrecks. ;)
Ja
aku x paham apa.. eh korang ni x de ke cara lagi senang?
Thanks for the snippet will be using it for my new (microformat) wordpress theme.
One thing to improve is the date and maybe add favicon as “photo” for each uri. what you think?