XML Sitemap & Google News feeds - Version 2.0

Version Description

  • priority calculation based on comments and age
  • changefreq based on comments
Download this release

Release Info

Developer RavanH
Plugin Icon 128x128 XML Sitemap & Google News feeds
Version 2.0
Comparing to
See all releases

Code changes from version 1.0 to 2.0

Files changed (3) hide show
  1. readme.txt +45 -16
  2. template.php +29 -5
  3. xml-sitemap.php +1 -1
readme.txt CHANGED
@@ -4,27 +4,35 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravan
4
Tags: xml sitemap, sitemap, google sitemap, yahoo sitemap, msn sitemap, ask sitemap, search engine, feed
5
Requires at least: 2.5
6
Tested up to: 2.8
7
- Stable tag: 1.0
8
9
- Creates a feed that complies to the XML Sitemap protocol ready be submitted to Google, Yahoo, MSN, Ask.com and others.
10
11
== Description ==
12
13
- This plugin dynamicaly creates an XML feed that complies to the XML Sitemap protocol. The main advantages of this approach are simplicity (no need to change file or folder permissions or move files) and the fact that this method works out-of-the-box on shared codebase / multi-blog setups like [WordPress MU](http://mu.wordpress.org/), [WP_OneInstall](http://wordpress.org/extend/plugins/wp-oneinstall/), [WP Hive](http://wordpress.org/extend/plugins/wp-hive/) and others.
14
15
- It requires no options to be set and instantly creates the feed of all posts on http://yourblogurl.tld/sitemap.xml and http://yourblogurl.tld/feed/sitemap. Ready to be submitted to search engines like Google, Yahoo, MSN, Ask.com and others. An entry `Sitemap: http://yourblogurl.tld/sitemap.xml` is added to the (by WordPress dynamicly created) robots.txt on http://yourblogurl.tld/robots.txt that will tell search engines visiting your blog where to find the XML Sitemap.
16
17
- It was based on the plugin Standard XML Sitemap Generator by Patrick Chia but requires no modifications to file locations. Some small improvements and a bugfix were done in the first version.
18
19
- Current version limits:
20
- * The feed contains the front page and all posts (normal pages are treated as posts) but excludes category, tag and other dynamic archive pages.
21
- * The number of posts listed in the sitemap is limited to 1000. Please let me know if you need more than that :)
22
23
== Installation ==
24
25
= Wordpress =
26
27
- Just use that slick installation and auto update feature on your Pugins page - OR - follow these simple steps:
28
29
1. Download archive and unpack.
30
@@ -32,32 +40,53 @@ Just use that slick installation and auto update feature on your Pugins page - O
32
33
3. Activate the plugin on the Plug-ins page.
34
35
- Done! Check your sparkling new XML Sitemap by adapting the url http://yourblogurl.tld/sitemap.xml to your blog and visiting it with a browser or online XML Sitemap validator. You might also want to see if the sitemap is listed in your http://yourblogurl.tld/robots.txt file.
36
37
= Wordpress MU =
38
39
- The plugin also works from the /mu-plugins/ folder where it works quietly in the background without bothering any blog owner with new options or the need for extra knowledge of XML Sitemap submission. Just upload the cpmplete package content and move the file xml-sitemap.php from /mu-plugins/xml-sitemap-feed/ to /mu-plugins/.
40
41
== Frequently Asked Questions ==
42
43
= Can I change the sitemap name/URL? =
44
45
- No. The sitemap url that you manually submit too Google (if you are impatient) should be http://yourblogurl.tld/sitemap.xml but is also available via http://yourblogurl.tld/feed/sitemap
46
47
- = I found no sitemap file in my blog! =
48
49
The sitemap is dynamically generated just like a feed. There is no actual file created.
50
51
= Where can I customize the xml output? =
52
53
- You may edit the XML output in template.php but be carefull not to break Sitemap protocol comliance. Read more on [Sitemaps XML format](http://www.sitemaps.org/protocol.php).
54
55
- = Do I need change my robots.txt? =
56
57
- No. Your sitemap url will be automatically added to your dynamic robots.txt when plugin actived. Unless you have a static file robots.txt in your root. In that case you might want to open it in a text editor and add a line like `Sitemap: http://yourblogurl.tld/sitemap.xml` to it.
58
59
== Changelog ==
60
61
= 1.0 =
62
* changed feed template location to avoid the need to relocate files outside the plugins folder
63
* bugfix: get_post_modified_time instead of get_post_time
4
Tags: xml sitemap, sitemap, google sitemap, yahoo sitemap, msn sitemap, ask sitemap, search engine, feed
5
Requires at least: 2.5
6
Tested up to: 2.8
7
+ Stable tag: 2.0
8
9
+ Creates a feed that complies to the XML Sitemap protocol ready to be submitted to Google, Yahoo, MSN, Ask.com and others.
10
11
== Description ==
12
13
+ This plugin dynamically creates an XML feed that complies to the XML Sitemap protocol. There are no options to be set and the feed becomes instantly available after activation on yourblogurl.tld/sitemap.xml and yourblogurl.tld/feed/sitemap ready to be submitted to search engines like Google, Yahoo, MSN, Ask.com and others. An entry `Sitemap: http:// yourblogurl.tld/sitemap.xml` is added to the (by WordPress dynamically created) robots.txt on yourblogurl.tld/robots.txt to tell search engines where to find your XML Sitemap.
14
15
+ The main advantages of this approach are **simplicity** (no need to change file or folder permissions or move files) and the fact that this method works out-of-the-box on **shared codebase / multi-blog setups** like [WordPress MU](http://mu.wordpress.org/), [WP_OneInstall](http://wordpress.org/extend/plugins/wp-oneinstall/), [WP Hive](http://wordpress.org/extend/plugins/wp-hive/) and others.
16
17
+ It was based on the plugin Standard XML Sitemap Generator by Patrick Chia but requires no modifications to file locations. Some other small improvements and a bugfix were done in the first version.
18
19
+ = Limitations =
20
+
21
+ * The feed contains the front page and all posts and pages but (still) excludes category, tag and other dynamic archive pages.
22
+ * There is no way (yet) to manually change the priority of posts/pages in the sitemap but since version 2.0 there is some basic automatic priority calculation (based on post age and comment activity) doing the work for you.
23
+ * The number of posts listed in the sitemap is limited to 1000. This should satisfy most blogs while limiting the sitemap size on bigger blogs by stripping of the oldest posts. Please let me know if you need more than your most recent 1000 posts listed in your sitemap.xml :)
24
+
25
+ = Translations =
26
+
27
+ There is nothing to translate. The sitemap protocol is international, there is no options page nor any front-end output. Nothing to see here, please move along ;)
28
29
== Installation ==
30
31
= Wordpress =
32
33
+ Just use that slick installation and auto update feature on your Pugins page
34
+ - OR -
35
+ follow these simple steps:
36
37
1. Download archive and unpack.
38
40
41
3. Activate the plugin on the Plug-ins page.
42
43
+ Done! Check your sparkling new XML Sitemap by adapting the url yourblogurl.tld/sitemap.xml to your blog and visiting it with a browser or online XML Sitemap validator. You might also want to see if the sitemap is listed in your yourblogurl.tld/robots.txt file.
44
45
= Wordpress MU =
46
47
+ The plugin also works from the /mu-plugins/ folder where it runs quietly in the background without bothering any blog owner with new options or the need for extra knowledge of XML Sitemap submission. Just upload the complete package content and move the file xml-sitemap.php from /mu-plugins/xml-sitemap-feed/ to /mu-plugins/.
48
49
== Frequently Asked Questions ==
50
51
+ = How are the values for priority and changefreq calculated? =
52
+
53
+ The front page has a priority of 1.0, pages are always 0.6 and posts will have a priority between 0.8 and 0.3 depending on comments and its age. the cangefreq of the frontpage is set to daily, monthly for pages and either monthly or weekly for posts depending on comments.
54
+
55
+ Dynamic pages like category pages, tag pages and archive pages are not listed in this version yet.
56
+
57
+ = Do I need to submit the sitemap to search engines? =
58
+
59
+ No. In normal circumstances, your site will be indexed by the major search engines before you know it. The search engines will be looking for a robots.txt file and (with this plugin activated) find a pointer in it to the XML Sitemap on your blog. The search engines will return on a regular basis to see if your site has updates.
60
+
61
+ = Does this plugin ping search engines? =
62
+
63
+ No. While other XML Sitemap plugins provide pinging to some search engines upon each post edit or publication, this plugin does not. For the average website, in my experience, pinging Google or others after each little change does not benefit anything except a theoretical smaller delay in re-indexation of your website. This is only theoretical because if your site is popular and active, major search engines will likely be crawling your site on a very regular basis anyway. And if, on the other hand, your site is not high in the agenda with the major search engines, they will likely give no priority to your pings anyway.
64
+
65
+ If you **really** feel the need to get your latest post indexed ASAP, you can let major search engines know about updates manually. For most search engines you need to have some account for that. Like a [Google Webmaster Tools account](https://www.google.com/webmasters/tools/) which will tell you much interesting things about your website and your readers. Try it!
66
+
67
= Can I change the sitemap name/URL? =
68
69
+ No. The sitemap url that you manually submit to Google (if you are impatient) should be yourblogurl.tld/sitemap.xml
70
+ The feed is also available via yourblogurl.tld/feed/sitemap
71
72
+ = I see no sitemap.xml file in my server space! =
73
74
The sitemap is dynamically generated just like a feed. There is no actual file created.
75
76
= Where can I customize the xml output? =
77
78
+ You may edit the XML output in xml-sitemap-feed/template.php but be carefull not to break Sitemap protocol comliance. Read more on [Sitemaps XML format](http://www.sitemaps.org/protocol.php).
79
80
+ = Do I need to change my robots.txt? =
81
82
+ No. Your sitemap url will be automatically added to your dynamic robots.txt when plugin actived. Unless you use a static robots.txt file in your website root. In that case you areadvised to open it in a text editor and add a line like `Sitemap: http:// yourblogurl.tld/sitemap.xml` (adapt to your site url).
83
84
== Changelog ==
85
86
+ = 2.0 =
87
+ * priority calculation based on comments and age
88
+ * changefreq based on comments
89
+
90
= 1.0 =
91
* changed feed template location to avoid the need to relocate files outside the plugins folder
92
* bugfix: get_post_modified_time instead of get_post_time
template.php CHANGED
@@ -1,6 +1,6 @@
1
<?php
2
/**
3
- * XML Sitemap Feed Template 1.0
4
**/
5
6
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'feed-sitemap.php' == basename($_SERVER['SCRIPT_FILENAME']))
@@ -9,15 +9,23 @@ if (!empty($_SERVER['SCRIPT_FILENAME']) && 'feed-sitemap.php' == basename($_SERV
9
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
10
$more = 1;
11
12
?>
13
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
14
- <!-- generator="XML Sitemap WordPress plugin/1.0" -->
15
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
16
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
17
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
18
<url>
19
<loc><?php bloginfo_rss('url') ?></loc>
20
- <lastmod><?php echo mysql2date('Y-m-d\TH:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastmod>
21
<changefreq>daily</changefreq>
22
<priority>1.0</priority>
23
</url>
@@ -34,12 +42,28 @@ if ($post_ids) {
34
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt DESC");
35
foreach ($posts as $post) {
36
setup_postdata($post);
37
?>
38
<url>
39
<loc><?php the_permalink_rss() ?></loc>
40
- <lastmod><?php echo mysql2date('Y-m-d\TH:i:s +0000', get_post_modified_time('Y-m-d H:i:s', true), false); ?></lastmod>
41
<changefreq>monthly</changefreq>
42
- <priority>0.6</priority>
43
</url>
44
<?php }
45
}
1
<?php
2
/**
3
+ * XML Sitemap Feed Template 2.0
4
**/
5
6
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'feed-sitemap.php' == basename($_SERVER['SCRIPT_FILENAME']))
9
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
10
$more = 1;
11
12
+ $lastpostmodified = get_lastpostmodified('GMT');
13
+
14
+ $post_priority = 0.7;
15
+ $minpost_priority = 0.3;
16
+ $maxpost_priority = 0.9;
17
+ $page_priority = 0.6;
18
+ $frontpage_priority = 1.0;
19
+
20
?>
21
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
22
+ <!-- generator="XML Sitemap Feed WordPress plugin/1.0" -->
23
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
25
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
26
<url>
27
<loc><?php bloginfo_rss('url') ?></loc>
28
+ <lastmod><?php echo mysql2date('Y-m-d\TH:i:s +0000', $lastpostmodified, false); ?></lastmod>
29
<changefreq>daily</changefreq>
30
<priority>1.0</priority>
31
</url>
42
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt DESC");
43
foreach ($posts as $post) {
44
setup_postdata($post);
45
+ $post_modified_time = get_post_modified_time('Y-m-d H:i:s', true);
46
+ $priority_down = (($lastpostmodified - $post_modified_time) > 0) ? ($lastpostmodified - $post_modified_time)/10 : 0;
47
+ $priority_up = ($post->comment_count > 0) ? $post->comment_count/10 : 0;
48
+ $priority = $post_priority - $priority_down + $priority_up;
49
+ $priority = ( $priority > $maxpost_priority ) ? $maxpost_priority : $priority;
50
+ $priority = ( $priority < $minpost_priority ) ? $minpost_priority : $priority;
51
?>
52
<url>
53
<loc><?php the_permalink_rss() ?></loc>
54
+ <lastmod><?php echo mysql2date('Y-m-d\TH:i:s +0000', $post_modified_time, false) ?></lastmod>
55
+ <?php if($post->post_type == "page") { ?>
56
+ <changefreq>monthly</changefreq>
57
+ <priority>0.5</priority>
58
+ <?php } else {
59
+ if($post->comment_count > 0) { ?>
60
+ <changefreq>weekly</changefreq>
61
+ <?php } else { ?>
62
<changefreq>monthly</changefreq>
63
+ <?php } ?>
64
+ <priority><?php echo $priority ?></priority>
65
+ <?php //echo "<test>" . $post_priority . " - " . $priority_down . " + " . $priority_up . "</test>" ?>
66
+ <?php } ?>
67
</url>
68
<?php }
69
}
xml-sitemap.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: XML Sitemap Feed
4
Plugin URI: http://4visions.nl/en/index.php?section=57
5
Description: Creates a dynamic XML feed that complies to the XML Sitemap protocol ready be submitted to Google, Yahoo, MSN, Ask.com and others. Based on the Standard XML Sitemap Generator by Patrick Chia.
6
- Version: 1.0
7
Author: RavanH
8
Author URI: http://4visions.nl/
9
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed&item_number=2%2e6%2e2%2e9&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8
3
Plugin Name: XML Sitemap Feed
4
Plugin URI: http://4visions.nl/en/index.php?section=57
5
Description: Creates a dynamic XML feed that complies to the XML Sitemap protocol ready be submitted to Google, Yahoo, MSN, Ask.com and others. Based on the Standard XML Sitemap Generator by Patrick Chia.
6
+ Version: 2.0
7
Author: RavanH
8
Author URI: http://4visions.nl/
9
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed&item_number=2%2e6%2e2%2e9&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8