I was never able to get the sitemap plugin working myself, but then after a bit of searching, I came across Igor Kromin's blog, in which he made his own
sitemap code, and it couldn't be simpler to use (seriously, the guy is a master at Flatpress). The code I'll share below also includes his
updated version of the code, which allows the sitemap to also index static page links after the blog entries. You can see his linked blog entry for more details on that.
First off, make a file called "sitemap.php" in the root of your flatpress install (where index.php is), and fill it with the following code:
Code: Select all
<?php
require_once('defaults.php');
require_once(INCLUDES_DIR.'includes.php');
if (function_exists('system_init')) {
system_init();
}
else {
plugin_loadall();
}
header('Content-Type: text/xml; charset=utf-8');
error_reporting(E_ALL);
echo("<?");
?>xml version="1.0" encoding="UTF-8"<?php echo("?>"); ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc><?=BLOG_BASEURL?></loc>
<lastmod><?=date("c");?></lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<?
$q = new FPDB_Query(array('start'=>0, 'count'=>-1, 'fullparse'=>true), null);
while($q->hasMore()) {
list($id, $e) = $q->getEntry();
$offset = $fp_config['locale']['timeoffset'];
if (isset($e['lastupdate'])) {
$lastmod = $e['lastupdate'] - (60 * 60 * $offset);
}
else {
$lastmod = $e['date'] - (60 * 60 * $offset);
}
$loc = BLOG_BASEURL . "index.php?x=entry:" . $id;
?>
<url>
<loc><?=$loc?></loc>
<lastmod><?=date("c", $lastmod);?></lastmod>
</url>
<?php
}
$ss = static_getlist();
foreach($ss as $k => $val) {
$s = static_parse($val);
$i = BLOG_BASEURL . '?page=' . $val;
$offset = $fp_config['locale']['timeoffset'];
$d = $s['date'] - (60 * 60 * $offset);
$d = date('c', $d);
echo('<url><loc>' . $i . '</loc><lastmod>' . $d . '</lastmod></url>');
}
?>
</urlset>
Simply save that, and in your browser, go to "YOUR-BLOG-URL.com/sitemap.php" and you'll have a fully generated sitemap.
Now, if you're using prettyurls, then the urs in the sitemap won't match what your blog url usually says... these links will still work, but you're using prettyurls for a reason, right?!
We can easily fix this by changing a single line of code. In your "sitemap.php" file, find the line that says:
Code: Select all
$loc = BLOG_BASEURL . "index.php?x=entry:" . $id;
And change it to:
Then, if you want to remove "?page=" from the URLs of your static pages in the sitemap, simply find the line that says:
Code: Select all
$i = BLOG_BASEURL . '?page=' . $val;
And change it to:
That should fix everything!
As an added part to this post, if you don't want to include Static pages for whatever reason, simply change:
Code: Select all
<?php
}
$ss = static_getlist();
foreach($ss as $k => $val) {
$s = static_parse($val);
$i = BLOG_BASEURL . '?page=' . $val;
$offset = $fp_config['locale']['timeoffset'];
$d = $s['date'] - (60 * 60 * $offset);
$d = date('c', $d);
echo('<url><loc>' . $i . '</loc><lastmod>' . $d . '</lastmod></url>');
}
?>
</urlset>
To:
And that should be it! According to the original blog, this code generates a "Google compatible sitemap", which is what I think we're all pretty much after.
You can obviously go on to modify the code as you wish, but this is a good start, I think.