How to select which albums to display using Flickr Photo Album
I’m using the Flickr Photo Album plugin for WordPress in another web page which I’ve recently had to update to WP2.7.1. So I decided to update also the mentioned plugin to version 1.1. The updating process was smooth, but I realized there was a set (album) I didn’t want to show in my web… so I asked myself:
Can you select which albums to display?
The answer was neither clear nor clean, that’s why I decided to explore the plugin code in order to find the exact point where I could filter which albums to show. And I found it. Of course there were other points, but this one satisfied both requirements:
- To affect every place where albums were used.
- Not to modify the internal code which connects to Flickr.
The file where this could be done was flickr/lib.flickr.php, exactly in the getAlbums() method:
function getAlbums() { $albums = $this->photosets_getList(); $visible_albums = array('123456789','123456789','123456789','123456789'); $return = array(); if (is_array($albums['photoset'])) foreach ($albums['photoset'] as $album) { if (in_array($album['id'], $visible_albums)) { $row = array(); $row['id'] = $album['id']; $row['title'] = $album['title']; $row['description'] = $album['description']; $row['primary'] = $album['primary']; $row['photos'] = $album['photos']; $row['pagename2'] = $this->_sanitizeTitle($album['title']); $row['pagename'] = $row['pagename2'] . '.html'; $return[$row['id']] = $row; } } return $return; }
It’s as easy as fill the visible_albums array with the ids of the albums you want to show. If in doubt just comment on this post and I’ll try to help you!