57 April 25, 2009

Wordpress Image Roll

on your blog sidebar or anywhere on your website.

imageroll

I’ve been receiving a lot of emails as regards to how I made those ‘chicklet’ images on my sidebar, is it comes natively from Wordpress or something? Well, I figured it worth a writeup [a five minutes walk-through] to sharing the good things, isn’t it?

Before we’re going to accomplished something like I did, you’ll need to download Asaph and make it work, it’s no hassle to set it up, give it a try.

Please note that Asaph isn’t a plugin for wordpress in anyway, it actually is a micro-blogging system but mainly focus on images like I introduced it before, they’re running separately on your server and never share a single database… which means that we need to figure another way out to cooking them. Originally, I was inspired by this recipe, it allows you to add display any rss feed on your blog by using Wordpress native function - wp_rss. Yeah!

Call It!

I assumed that your asaph is up and running, and you already bookmarked a few images, now you need to edit your wordpress theme template. The tricky part is that we’re going to use wp_rss to call asaph’s feed, here is the complete codes, you can add where you want the rss content to be displayed (your sidebar or any other page template):

<?php // Get RSS Feed
include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_rss('your-asaph-feed‘);
$maxitems = 24;
$items = array_slice($rss->items, 0, $maxitems);
?>
<ul>
<?php if (empty($items)) echo ‘<li>No items</li>’;
else
foreach ( $items as $item ) : ?>
<li><a href=’<?php echo $item['link']; ?>’>
<?php echo $item['description']; ?></a></li>
<?php endforeach; ?></ul>

where fetch_rss replace it with your actual feed url and $maxitems means how many items that you wanted to show, you can change the value you like. That’s it. yeah, it’s that simple.

More tweaks

since it works now it’s time for styling it, within CSS tweaks you can give it a nice looking, show your magic. It will be great if use some lightboxed effect, personally I use fancybox to visualized it in a better way. good luck!

I’d like to give a big thank you to my friend benhero who is an amazing ruby code ninja, he helped me on the codes and took me out of the fire :-)

Tagged as: , , , , , , , ,
Posted in: Blogging, Wordpress

Currently 57 comments, want to say something now?

Say something...