Adding FAlbum URLs to XML-Sitemap WordPress Plugin
As I mentioned on my previous post yesterday about Fixing FAlbum Plugin that I'm trying to add support for Google XML Sitemaps Plugin to FAlbum so that all URLs including albums, photos and tags would be added to Blog’s Sitemap which would be crawled by Google, Yahoo and MSN .
Actually, Google XML Sitemaps Plugin made the job much easier by providing simple WordPress add_action() to add the URLs, so you only need to add one function inside 'wp-content/plugins/falbum/wordpress-falbum-plugin.php' to accomplish the job !
Edit file wp-content/plugins/falbum/wordpress-falbum-plugin.php and add these lines before the add_action lines
-
-
function addto_sitemaps(){
-
-
#add FAlbum url to Sitemaps
-
function FA_xml_url($pfx=”){
-
if( ($FA_xml_go=&GoogleSitemapGenerator::GetInstance()) == null) return;
-
$FA_xml_go->AddUrl( get_option(’siteurl').$GLOBALS['falbum']->create_url($pfx) , time() , "always", 0.8);
-
}
-
#creates extra pages depending on the limit you set for
-
#photos and albums per page
-
function FA_xml_pages($tot, $limit , $pfx = ” ){
-
for($i=1; $i <= $pages; $i++)
-
FA_xml_url( $pfx.'page/'.$i.'/' );
-
}
-
#creates photos urls
-
function FA_xml_get_photos( &$photos , $pfx , $type = 'photoset'){
-
$photo = $photos[$type]['photo'][$i];
-
$photo_id = $photo['id'];
-
$photo_title = $photo['title'];
-
-
$photo_link = $falbum->_get_link_title($photo_title, $photo_id, $photo_title_array);
-
FA_xml_url( "{$pfx}page/{$p}/photo/{$photo_link}/");
-
}
-
}
-
#disable administrator user_level to hide secret sets
-
$GLOBALS['user_level'] = 0;
-
-
#getting Flickr albums
-
$albums = $falbum->_call_flickr_php('flickr.photosets.getList', array ("user_id" => $falbum->options['nsid']));
-
#creating main album extra pages
-
-
#inserting recent photos pages
-
$pfx = "show/recent/";
-
FA_xml_url( $pfx);
-
$photos = $falbum->_call_flickr_php('flickr.photos.search', array ('user_id' => $falbum->options['nsid'], ’sort' => 'date-taken-desc'));
-
-
#get recent pages
-
FA_xml_pages( ($falbum->options['number_recent'] == -1 ? $num : $falbum->options['number_recent']) , $falbum->options['photos_per_page'] , $pfx);
-
#get recent photos
-
FA_xml_get_photos( $photos , $pfx , 'photos');
-
-
#to avoid creating duplicates when creating urls
-
#creating albums urls
-
foreach($albums['photosets']['photoset'] as $album){
-
$id = $album['id'];
-
$title = $falbum->_unhtmlentities($album['title']['_content']);
-
$link_title = $falbum->_get_link_title($title, $id, $photo_title_array);
-
$pfx = "album/{$link_title}/";
-
FA_xml_url( $pfx);
-
#creating album extra pages
-
FA_xml_pages( $album['photos'] , $falbum->options['photos_per_page'] , $pfx);
-
-
#getting album photos
-
$photos = $falbum->_call_flickr_php('flickr.photosets.getPhotos', array ("photoset_id" => $album['id']));
-
FA_xml_get_photos( $photos , $pfx);
-
-
-
}
-
-
-
#inserting tags pages
-
FA_xml_url( "show/tags/");
-
$tags = $falbum->_call_flickr_php('flickr.tags.getListUserPopular', array ('count' => '500′, user_id => $falbum->options['nsid']));
-
-
foreach( $tags['who']['tags']['tag'] as $tag ){
-
$pfx = "tags/{$tag['_content']}/";
-
FA_xml_url( $pfx);
-
-
-
#getting tag photos
-
$photos = $falbum->_call_flickr_php('flickr.photos.search', array ('user_id' => $falbum->options['nsid'], 'tags' => $tag['_content'], 'tag_mode' => 'all'));
-
#tag pages
-
FA_xml_pages( $num, $falbum->options['photos_per_page'], $pfx);
-
-
FA_xml_get_photos( $photos , $pfx, 'photos');
-
-
}
-
}
-
add_action("sm_buildmap","addto_sitemaps");
-
you see a working preview of my Sitemap
*update 10Dec2007 : fixed photo links 302 redirection*


November 24th, 2007 at 2:37 am
Can the sitemap map things that are outside of WP? Photos, for instance?
November 24th, 2007 at 10:58 am
@whatisaurl : it’s a question to ask xml-sitemaps plugin support. however, you can add static pages manually and you don't need to add photos to sitemaps unless it’s for Google images search.
November 24th, 2007 at 12:35 pm
The static pages won't get overwritten when I update?
November 24th, 2007 at 12:54 pm
@whatisaurl : xml-sitemaps plugin store manually added static pages in the database so as far as you did not make any changes in the DB during the upgrade it will not change
March 31st, 2008 at 7:35 am
Hi! Whenever I paste your above script into wp-content/plugins/falbum/wordpress-falbum-plugin.php, it takes down my blog… running falbum 0.7.1 and sitemaps 3.0.3. Any suggestions? is it a pathing issue? (the blog sits at /blog, but it is actually at the root).
March 31st, 2008 at 10:25 am
@Matt
Please copy and paste the code again, or replace all unicode (’‘) with '
March 31st, 2008 at 4:39 pm
Thanks, I'll try– also, I didn't do your other updates from your other post… is it necessary to do that as well, or can I just do this one?
April 1st, 2008 at 4:25 pm
@Matt
Welcome! you don't need to add the fixes from the other post for adding falbum to sitemap to work.
April 29th, 2008 at 2:18 am
[...] to get xml-sitemaps and FAlbum to play nice together…not sure I have the time to do it! Adding FAlbum URLs to XML-Sitemap WordPress Plugin [...]