Adding Flickr Photos to your Wordpress Blog

May 11, 2007

We recently added a sidebar section of recent Flickr photos to the Pursue the Passion: The Journey blog. I wanted the code to just pull up the photos in Flickr, not within the actual blog, because the photos weren’t ready for this use yet. (They need to be labeled and organized properly.) This is how I did the code for it:

PLEASE READ THESE INSTRUCTIONS CAREFULLY.
If you do not understand them, please do not attempt this.

  1. Download, extract, install, activate and authorize FAlbum.
    The install instructions are in the readme file once you download and extract the .zip package. (You can also find some pretty good instructions on installing and activating FAlbum here.)
  2. Turn off friendly URLs.
    Go into the Wordpress Admin, select "Options" and then select "FAlbum". Set "Use Friendly URLs" to "false". This is important because you’re about to modify some code that would cause your site to not display properly if FAlbum’s rewrite rules are on.
  3. Modify the code.
    Open FAlbum.class.php in /wp-content/plugins/FAlbum/. Find line 1124 in the code. (Use a text editor with line numbers, like TextWrangler or TextPad.) Modify this line of code:
    $output .= "<a href=’".$this->create_url("show/recent/photo/$photo_link/")."’>";
    to say
    $output .= ‘<a href="http://www.flickr.com/photos/YOURACCOUNT/’ . $photo_link . ‘/">;
    where YOURACCOUNT is your Flickr account. For example, if your Flickr URL is http://www.flickr.com/photos/pursuethepassion/, then your Flickr account would be "pursuethepassion". Save this file and upload it back where it was.
  4. Modify your sidebar.
    Add this line of code to your sidebar
    <?php echo $falbum->show_recent(4,1,’s’); ?>
    and use CSS to decorate it any way you want.

And there you have it - a sidebar plugin that displays 4 recent photos and links them to your Flickr account.

AN UPDATE!!
The recent pictures were not getting updated as they were uploaded, so I had to change the plugin once again. Only attempt this if you are using the plugin in the manner described in this post - otherwise, you will cause some functions to stop working.

  1. Open the file FAlbum.class.php in /wp-content/plugins/FAlbum/.
  2. Do a search and replace, replacing "date-taken-desc" with "date-posted-desc".
  3. Save and upload.
  4. Go into your WordPress admin, go to the options, and choose the “FAlbum” tab. Click &quot”Clear Cache" and sign out of the WordPress admin.

Comments

Got something to say?