XML Sitemap & Google News feeds - Version 3.7

Version Description

  • massive changefreq calculation improvement
  • further priority calulation improvement taking last comment date into account
Download this release

Release Info

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

Code changes from version 3.6.1 to 3.7

Files changed (4) hide show
  1. feed-sitemap.php +79 -40
  2. readme.txt +47 -32
  3. sitemap.xsl.php +1 -1
  4. xml-sitemap.php +2 -2
feed-sitemap.php CHANGED
@@ -3,50 +3,62 @@
3
XML Sitemap Feed Template
4
--------------------------- */
5
6
- // presets
7
- $frontpage_priority = 1.0;
8
- $min_priority = 0.1;
9
- $max_priority = 0.9;
10
- $maxURLS = 9999; // 10,000 (including 1 for front page) of maximum 50,000 URLs allowed in a sitemap.xml
11
- // should be more than enough for any blog...
12
- $comment_weight = 0.1;
13
- $age_weight = 0.1;
14
- $level_weight = 0.1;
15
16
- // site variables
17
$_post_count = wp_count_posts('post');
18
$_page_count = wp_count_posts('page');
19
$_totalcommentcount = wp_count_comments();
20
21
- $lastpostmodified_GMT = get_lastpostmodified('GMT'); // last posts modified date
22
- $lastpostmodified = mysql2date('U',$lastpostmodified_GMT); // last posts modified date in Unix seconds
23
$firstpostmodified = mysql2date('U',get_firstpostmodified('GMT')); // get_firstpostmodified() function defined in xml-sitemap.php !
24
- $average_commentcount = $_totalcommentcount->approved/($_post_count->publish + $_page_count->publish);
25
26
// calculated presets
27
if ($_totalcommentcount->approved > 0)
28
$comment_weight = ($max_priority - $min_priority) / $_totalcommentcount->approved;
29
30
if ($_post_count->publish > $_page_count->publish) { // site emphasis on posts
31
- $post_priority = 0.7;
32
$page_priority = 0.4;
33
} else { // site emphasis on pages
34
$post_priority = 0.4;
35
- $page_priority = 0.7;
36
}
37
38
- if ( $lastpostmodified > $firstpostmodified )
39
- $age_weight = ($max_priority - $min_priority) / ($lastpostmodified - $firstpostmodified);
40
-
41
- // reset the query
42
- global $post;
43
- query_posts( array(
44
- 'posts_per_page' => $maxURLS,
45
- 'post_type' => 'any',
46
- 'post_status' => 'publish',
47
- 'caller_get_posts' => '1'
48
- )
49
- );
50
51
// start the xml output
52
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
@@ -62,19 +74,40 @@ echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?>
62
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
63
<url>
64
<loc><?php bloginfo_rss('url') ?>/</loc>
65
- <lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $lastpostmodified_GMT, false); ?></lastmod>
66
<changefreq>daily</changefreq>
67
<priority>1.0</priority>
68
</url>
69
<?php
70
// and loop away!
71
- while ( have_posts() ) : the_post();
72
73
if($post->post_type == "page") {
74
if ($post->ID == get_option('page_on_front')) // check if we are not doing the front page twice
75
continue;
76
77
- if (!is_array($post->ancestors)) { // $post->ancestors seems always empty. something to do with http://core.trac.wordpress.org/ticket/10381 ??
78
$page_obj = $post;
79
$ancestors = array();
80
while($page_obj->post_parent!=0) {
@@ -85,25 +118,31 @@ while ( have_posts() ) : the_post();
85
$ancestors = $post->ancestors;
86
}
87
$offset = (($post->comment_count - $average_commentcount) * $comment_weight) - (count($ancestors) * $level_weight);
88
- $priority = $page_priority + round($offset,1);
89
} else {
90
- $offset = (($post->comment_count - $average_commentcount) * $comment_weight) - (($lastpostmodified - mysql2date('U',$post->post_modified_gmt)) * $age_weight);
91
- $priority = $post_priority + round($offset,1);
92
}
93
$priority = ($priority > $max_priority) ? $max_priority : $priority;
94
$priority = ($priority < $min_priority) ? $min_priority : $priority;
95
?>
96
<url>
97
- <loc><?php the_permalink_rss() ?></loc>
98
- <lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $post->post_modified_gmt, false) ?></lastmod>
99
- <?php if($post->comment_count > ($_totalcommentcount->approved / 2)) { ?>
100
<changefreq>daily</changefreq>
101
- <?php } else if($post->comment_count > 0 ) { ?>
102
<changefreq>weekly</changefreq>
103
- <?php } else { ?>
104
<changefreq>monthly</changefreq>
105
<?php } ?>
106
- <priority><?php echo $priority ?></priority>
107
</url>
108
- <?php endwhile; ?>
109
</urlset>
3
XML Sitemap Feed Template
4
--------------------------- */
5
6
+ // presets are changable; please read comments.
7
+ $max_priority = 1.0; // Maximum priority value for any URL in the sitemap; set to any other value between 0 and 1.
8
+ $min_priority = 0; // Minimum priority value for any URL in the sitemap; set to any other value between 0 and 1.
9
+ // NOTE: Changing these values will influence each URL's priority. Priority values are taken by
10
+ // search engines to represent RELATIVE priority within the site domain. Forcing all URLs
11
+ // to a priority of above 0.5 or even fixing them all to 1.0 - for example - is useless.
12
+ $frontpage_priority = 1.0; // Your front page priority, usually the same as max priority but if you have any reason
13
+ // to change it, please be my guest; set to any other value between 0 and 1.
14
15
+ $maxURLS = -1; // When running into server memory problems, seeing a message like:
16
+ // "Fatal error: Allowed memory size of xxx bytes exhausted..."
17
+ // You might want to try setting the maxURLS value to 1000 and, if that works
18
+ // and if necessery, increment the value by 1000 until the sitemap lists all
19
+ // the posts.
20
+ $level_weight = 0.1; // Makes a sub-page loose 10% for each level; set to any other value between 0 and 1.
21
+ $month_weight = 0.1; // Fall-back value normally ignored by automatic priority calculation, which
22
+ // makes a post loose 10% of priority monthly; set to any other value between 0 and 1.
23
+
24
+ // editing below here is not advised!
25
+
26
+ // change the main query
27
+ query_posts( array(
28
+ 'posts_per_page' => $maxURLS,
29
+ 'post_type' => 'any',
30
+ 'post_status' => 'publish',
31
+ 'caller_get_posts' => '1'
32
+ )
33
+ );
34
+
35
+ // setup site variables
36
$_post_count = wp_count_posts('post');
37
$_page_count = wp_count_posts('page');
38
$_totalcommentcount = wp_count_comments();
39
40
+ $lastpostmodified_gmt = get_lastpostmodified('GMT'); // last posts modified date
41
+ $lastpostmodified = mysql2date('U',$lastpostmodified_gmt); // last posts modified date in Unix seconds
42
$firstpostmodified = mysql2date('U',get_firstpostmodified('GMT')); // get_firstpostmodified() function defined in xml-sitemap.php !
43
44
// calculated presets
45
if ($_totalcommentcount->approved > 0)
46
$comment_weight = ($max_priority - $min_priority) / $_totalcommentcount->approved;
47
+ else
48
+ $comment_weight = 0;
49
50
if ($_post_count->publish > $_page_count->publish) { // site emphasis on posts
51
+ $post_priority = 0.8;
52
$page_priority = 0.4;
53
} else { // site emphasis on pages
54
$post_priority = 0.4;
55
+ $page_priority = 0.8;
56
}
57
58
+ if ( $lastpostmodified > $firstpostmodified ) // valid blog age found ?
59
+ $age_weight = ($post_priority - $min_priority) / ($lastpostmodified - $firstpostmodified); // calculate relative age weight
60
+ else
61
+ $age_weight = $month_weight / 2629744 ; // else just do 10% per month (that's a month in seconds)
62
63
// start the xml output
64
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
74
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
75
<url>
76
<loc><?php bloginfo_rss('url') ?>/</loc>
77
+ <lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $lastpostmodified_gmt, false); ?></lastmod>
78
<changefreq>daily</changefreq>
79
<priority>1.0</priority>
80
</url>
81
<?php
82
+ // prepare counter to limit the number of URLs to the absolute max of 50.000
83
+ $counter = 1;
84
+
85
// and loop away!
86
+ if ( have_posts() ) : while ( have_posts() && $counter < 50000 ) : the_post();
87
+
88
+ $thispostmodified_gmt = $post->post_modified_gmt; // post GMT timestamp
89
+ $thispostmodified = mysql2date('U',$thispostmodified_gmt); // post Unix timestamp
90
+ $lastcomment = array();
91
+
92
+ if ($post->comment_count && $post->comment_count > 0) {
93
+ $lastcomment = get_comments( array(
94
+ 'status' => 'approve',
95
+ '$number' => 1,
96
+ 'post_id' => $post->ID,
97
+ ) );
98
+ $lastcommentsdate = mysql2date('U',$lastcomment[0]->comment_date_gmt); // last comment timestamp
99
+ if ( $lastcommentsdate > $thispostmodified ) {
100
+ $thispostmodified = $lastcommentsdate; // replace post with comment Unix timestamp
101
+ $thispostmodified_gmt = $lastcomment[0]->comment_date_gmt; // and replace modified GMT timestamp
102
+ }
103
+ }
104
+ $lastactivityage = (gmdate('U') - $thispostmodified); // post age
105
106
if($post->post_type == "page") {
107
if ($post->ID == get_option('page_on_front')) // check if we are not doing the front page twice
108
continue;
109
110
+ if (!is_array($post->ancestors)) { // $post->ancestors seems always empty (something to do with http://core.trac.wordpress.org/ticket/10381 ?) so we probably need to do it ourselves...
111
$page_obj = $post;
112
$ancestors = array();
113
while($page_obj->post_parent!=0) {
118
$ancestors = $post->ancestors;
119
}
120
$offset = (($post->comment_count - $average_commentcount) * $comment_weight) - (count($ancestors) * $level_weight);
121
+ $priority = $page_priority + $offset;
122
} else {
123
+ $offset = (($post->comment_count - $average_commentcount) * $comment_weight) - (($lastpostmodified - $thispostmodified) * $age_weight);
124
+ $priority = $post_priority + $offset;
125
}
126
+ // trim priority
127
$priority = ($priority > $max_priority) ? $max_priority : $priority;
128
$priority = ($priority < $min_priority) ? $min_priority : $priority;
129
?>
130
<url>
131
+ <loc><?php the_permalink() ?></loc>
132
+ <lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $thispostmodified_gmt, false) ?></lastmod>
133
+ <?php if(($lastactivityage/86400) < 7) { // last activity less than 1 week old ?>
134
<changefreq>daily</changefreq>
135
+ <?php } else if(($lastactivityage/604800) < 12) { // last activity between 1 and 12 weeks old ?>
136
<changefreq>weekly</changefreq>
137
+ <?php } else if(($lastactivityage/604800) < 52) { // last activity between 12 and 52 weeks old ?>
138
<changefreq>monthly</changefreq>
139
+ <?php } else { ?>
140
+ <changefreq>yearly</changefreq>
141
<?php } ?>
142
+ <priority><?php echo round($priority,1) ?></priority>
143
</url>
144
+ <?php
145
+ $counter++;
146
+
147
+ endwhile; endif; ?>
148
</urlset>
readme.txt CHANGED
@@ -1,39 +1,40 @@
1
=== XML Sitemap Feed ===
2
Contributors: RavanH
3
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap&item_number=3%2e0&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8
4
- Tags: sitemap, xml sitemap, google, yahoo, bing, feed, wpmu
5
Requires at least: 2.6
6
Tested up to: 3.0
7
- Stable tag: 3.6.1
8
9
Creates a feed that complies with the XML Sitemap protocol ready for indexing by Google, Yahoo, Bing, Ask and others.
10
11
== Description ==
12
13
- This plugin dynamically creates an XML feed that complies with the XML Sitemap protocol. There are no options to be set and the feed becomes instantly available after activation on yourblogurl.tld/sitemap.xml (or yourblogurl.tld/index.php?feed=sitemap if you do not use a fancy permalink structure) ready for indexing by search engines like Google, Yahoo, MSN, Ask.com and others.
14
15
- 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. If you do not use fancy URL's in WordPress, have WP installed in a subdirectory or if you use WP for pages only and do not have any posts, WordPress does not generate a robots.txt output. You will have to create your own robots.txt file and upload it to your site root. See FAQ's.
16
17
= Advantages =
18
19
* The main advantage of this plugin over other XML Sitemap plugins is **simplicity**. No need to change file or folder permissions, move files or spend time on a difficult plugin options page. In fact, there are no options at all!
20
- * Works out-of-the-box on **multi-site / shared codebase / multi-blog setups** like [WordPress MU](http://mu.wordpress.org/), WP 3.0 in MS mode and others.
21
- * Automatic post URL priority calculation based on post age and comment/trackback activity.
22
- * Works both when **Network Activated** or placed in **/mu-plugins/** on WP 3.0 in Mutli site mode and WPMU.
23
24
= Limitations =
25
26
- * The feed contains the front page and all posts and pages but _excludes_ category, tag and other dynamic archive pages. This should not be a problem and by some it is even advised. There are SEO plugins around that even make these archive pages non-indexable by search engines.
27
- * Except by _resaving_ older posts from time to time (keeping the lastmod date fairly recent to ensure automatic high priority calculation for those urls) there is no way to manually set the priority of individual posts/pages in the sitemap. See the Faq's for more.
28
* This plugin does not ping any search engines. But then, WordPress does this by default already via the Ping-o-Matic service so why bother? See the Faq's for more.
29
30
= Translations =
31
32
- There is nothing to translate. The sitemap protocol is international, there is no options page nor any front-end / widget output. Nothing to see here, please move along ;)
33
34
= Credits =
35
- XML Sitemap Feed was originally based on the (discontinued?) plugin Standard XML Sitemap Generator by Patrick Chia. Many thanks! Since then, it has been completely rewriten.
36
37
38
== Installation ==
39
@@ -51,7 +52,9 @@ follow these simple steps:
51
52
3. Activate the plugin on the Plug-ins page.
53
54
- Done! Check your sparkling new XML Sitemap by visiting yourblogurl.tld/sitemap.xml (adapted to your domain name ofcourse) with a browser or any online XML Sitemap validator. You might also want to check if the sitemap is listed in your yourblogurl.tld/robots.txt file.
55
56
= WordPress 3+ in Multi Site mode =
57
@@ -61,27 +64,27 @@ Same as above but do a **Network Activate** to make a XML sitemap available for
61
62
The plugin works best from the **/mu-plugins/** folder where it runs quietly in the background without bothering any blog owner with new options or the need for special knowledge of XML Sitemap submission. Just upload the complete package content to /mu-plugins/ and move the file xml-sitemap.php from the new /mu-plugins/xml-sitemap-feed/ to /mu-plugins/.
63
64
- Installed in /mu-plugins/ alongside [WordPress MU Sitewide Tags Pages](http://wordpress.org/extend/plugins/wordpress-mu-sitewide-tags/), XML Sitemap Feed will **not** create a sitemap.xml nor change robots.txt for any tag blogs. They would be full of links outside the tags blogs own domain and subsequently ignored (or worse: penalized) by Google.
65
66
== Frequently Asked Questions ==
67
68
= How are the values for priority and changefreq calculated? =
69
70
- The front page has a fixed priority of 100% (1.0). When your site has more posts that pages (you must be using WordPress for a blog), pages have a default priority of 40% (0.4) and posts have a default priority of 70% (0.7). If your site has more pages than posts (you must be using WordPress as CMS), pages have a default priority of 70% (0.7) and posts have a default priority of 40% (0.4).
71
72
- Page priotity can vary between 10% (0.1) and 90% (0.9) depending on the page level (decreasing 10% for each sub-level) and relative number of comments. Post priority can vary between 10% (0.1) and 90% (0.9) depending on relative number of comments and relative post age.
73
74
- The cangefreq of the frontpage is fixed to daily and calculated for pages and post to either monthly, weekly or daily depending on comments.
75
76
Dynamic pages like category pages, tag pages and archive pages are not listed in the XML Sitemap.
77
78
= Can I manipulate values for priority and changefreq? =
79
80
- Yes and No. This plugin has no options page so there is no way to manually set the priority of urls in the sitemap. But there is automatic post priority calculation based on _post modifaction date_ and comment activity, that can either make post priority go to 90% (0.9) for fairly recent posts with many comments or 10% (0.1) for very old posts with no comments.
81
82
- This feature can be used to your advantage: by resaving your most important older posts from time to time, keeping the **lastmod date** fairly recent, you can ensure a priority of at least 70% (0.7) for those urls. And if you have comments on on those pages, the priority will even go up to 90% (0.9).
83
84
- If you cannot live with these rules, edit the values `$post_priority`, `$minpost_priority`, `$maxpost_priority`, `$page_priority`, `$frontpage_priority` in xml-sitemap-feed/sitemap.xml.php
85
86
= Do I need to submit the sitemap to search engines? =
87
@@ -103,17 +106,13 @@ Read more on [Ping-O-Matic](http://pingomatic.com) about what excellent service
103
104
2. 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 on the agenda of the major search engines, they will likely give no priority to your pings at all.
105
106
- You can always take a [Google Webmaster Tools account](https://www.google.com/webmasters/tools/) which will tell you many interesting things about your website, search terms and your visitors. Try it!
107
-
108
- = I see no sitemap.xml file in my server space! =
109
-
110
- The sitemap is dynamically generated just like a feed. There is no actual file created.
111
112
= Do I need to change my robots.txt? =
113
114
That depends. In normal circumstances, if you have no physical robots.txt file in your site root, the new sitemap url will be automatically added to the dynamic robots.txt that is generated by WordPress. But in some cases this might not be the case.
115
116
- If you use a static robots.txt file in your website root, you will need to open it in a text editor and add a line like `Sitemap: http://yourblogurl.tld/sitemap.xml` (adapt to your site url) to make search engines find your XML Sitemap.
117
118
Or if you have WP installed in a subdirectory, on a server without rewrite_rules or if you do not use fancy URLs in your Permalink structure settings. In these cases, WordPress will need a little help in getting ready for XML Sitemap indexing. Read on in the **WordPress** section for more.
119
@@ -121,10 +120,10 @@ Or if you have WP installed in a subdirectory, on a server without rewrite_rules
121
122
That depends on where the index.php and .htaccess of your installation resides. If it is in the root, meaning WP is installed in a subdir but the blog is accessible from your domain root, you do not have to do anything. It should work out of the box. However, if the index.php is (e.g. still with your wp-config.php and all other WP files) in a subdir, meaning your blog is only accessible via that subdir, you need to manage your own robots.txt file in your domain root. It _has_ to be in the root (!) and needs a line starting with `Sitemap:` followed by the full URL to the sitemap feed provided by XML Sitemap Feed plugin. Like:
123
`
124
- Sitemap: http://yourblogurl.tld/subdir/sitemap.xml
125
`
126
127
- If you already have a robots.txt file with a line like that, you might want to read more about creating an XML Sitemap Index on [sitemaps.org](http://www.sitemaps.org/protocol.php#index).
128
129
= Do I need to use a fancy Permalink structure? =
130
@@ -137,18 +136,26 @@ Sitemap: http://yourblogurl.tld/index.php?feed=sitemap
137
User-agent: *
138
Allow: /
139
`
140
- You can also choose to notify major search engines of your new XML sitemap manually. Start with getting a [Google Webmaster Tools account](https://www.google.com/webmasters/tools/) or head over to [XML-Sitemaps.com](http://www.xml-sitemaps.com/validate-xml-sitemap.html) and enter your sites sitemap URL.
141
142
= Can I change the sitemap name/URL? =
143
144
- No. If you have fancy URL's turned ON in WordPress (Permalinks), the sitemap url that you manually submit to Google (if you are impatient) should be `yourblogurl.tld/sitemap.xml` or `yourblogurl.tld/feed/sitemap/` but if you have the Permalinks' Default option set the feed is only available via `yourblogurl.tld/?feed=sitemap`.
145
146
= Where can I customize the xml output? =
147
148
- You may edit the XML output in `xml-sitemap-feed/sitemap.xml.php` but be carefull not to break Sitemap protocol comliance. Read more on [Sitemaps XML format](http://www.sitemaps.org/protocol.php).
149
150
The stylesheet (to make the sitemap human readable) can be edited in `xml-sitemap-feed/sitemap.xsl.php`.
151
152
= I get a 404 page instead of both sitemap.xml and robots.txt! =
153
154
There are plugins like Event Calendar (at least v.3.2.beta2) known to mess with rewrite rules, causing problems with WordPress internal feeds and robots.txt generation and thus conflict with the XML Sitemap Feed plugin. Deactivate all plugins and see if you get a basic robots.txt file showing:
@@ -164,19 +171,27 @@ There is a know issue with WordPress (at least up to 2.8) not generating a robot
164
165
To get around this, you might either at least write one post and give it _Private_ status or alternatively create your own robots.txt file containing:
166
`
167
- Sitemap: http://yourblogurl.tld/sitemap.xml
168
169
User-agent: *
170
Allow: /
171
`
172
and upload it to your web root...
173
174
- = Can I do a Network Activate with this plugin on WP3.0 MS / WPMU ? =
175
176
Yes.
177
178
== Changelog ==
179
180
= 3.6.1 =
181
* BUGFIX: wrong date calculation on blogs less than 1 year old
182
1
=== XML Sitemap Feed ===
2
Contributors: RavanH
3
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap&item_number=3%2e0&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8
4
+ Tags: sitemap, xml sitemap, sitemap.xml, google, yahoo, bing, wpmu, feed
5
Requires at least: 2.6
6
Tested up to: 3.0
7
+ Stable tag: 3.7
8
9
Creates a feed that complies with the XML Sitemap protocol ready for indexing by Google, Yahoo, Bing, Ask and others.
10
11
== Description ==
12
13
+ This plugin dynamically creates an XML feed that complies with the XML Sitemap protocol. There are no options to be set and the feed becomes instantly available after activation on yourblogurl.tld/feed/sitemap/ and for backward compatibility on yourblogurl.tld/sitemap.xml or yourblogurl.tld/index.php?feed=sitemap if you do not use a fancy permalink structure, ready for indexing by search engines like Google, Yahoo, MSN, Ask.com and others.
14
15
+ A reference to it is added to your (by WordPress dynamically created) robots.txt on yourblogurl.tld/robots.txt to tell search engines where to find your XML Sitemap. If you do not use fancy URL's in WordPress, if you have WP installed in a subdirectory or if you use WP for pages only and do not have any posts, WordPress does not generate a robots.txt output. You'll have to create your own and upload it to your site root. See FAQ's.
16
17
= Advantages =
18
19
* The main advantage of this plugin over other XML Sitemap plugins is **simplicity**. No need to change file or folder permissions, move files or spend time on a difficult plugin options page. In fact, there are no options at all!
20
+ * Completely **automatic** post URL _priority_ and _change frequency_ calculation based on post age and comment/trackback activity.
21
+ * Works out-of-the-box, even on **multi-site / shared codebase / multi-blog setups** like [WordPress MU](http://mu.wordpress.org/), WP 3.0 in MultiSite mode and others.
22
+ * Also works when **Network Activated** or placed in **/mu-plugins/** on WP 3.0 in MS mode and WPMU and even takes care to exclude any tags blogs to avoid malus points for link spamming.
23
24
= Limitations =
25
26
+ * The feed contains the front page and all posts and pages but _excludes_ category, tag and other dynamic archive pages. This should not be a problem and by most it is even advised. There even are SEO plugins around that actively make these archive pages non-index-able by search engines.
27
+ * Except by _re-saving_ older posts from time to time (keeping the lastmod date fairly recent to ensure automatic high priority calculation for those urls) there is no way to manually set the priority of individual posts/pages in the sitemap. See the Faq's for more.
28
* This plugin does not ping any search engines. But then, WordPress does this by default already via the Ping-o-Matic service so why bother? See the Faq's for more.
29
+ * Since the feed is dynamically created, on _very_ large sites the creation process might take a while. Search engines are said to have a short fuse about waiting for a sitemap, so if your site is huge you may want to consider using a cache plugin that also (pre)caches feeds. If you are unfamiliar with caching and server setup start with a simple plugin such as Quick Cache but if you are looking for more options you might find solace in WP Super Cache of W3 Total Cache.
30
31
= Translations =
32
33
+ There is nothing to translate. The sitemap protocol is international, there is no options page nor any front-end or widget output. Nothing to see here, please move along ;)
34
35
= Credits =
36
37
+ XML Sitemap Feed was originally based on the (discontinued?) plugin Standard XML Sitemap Generator by Patrick Chia. Many thanks! Since then, it has been completely rewriten.
38
39
== Installation ==
40
52
53
3. Activate the plugin on the Plug-ins page.
54
55
+ 4. If you have been using another XML Sitemap plugin before, check your site root and remove any created sitemap.xml file that remained there.
56
+
57
+ Done! Check your sparkling new XML Sitemap by visiting yourblogurl.tld/feed/sitemap/ (adapted to your domain name ofcourse) with a browser or any online XML Sitemap validator. You might also want to check if the sitemap is listed in your yourblogurl.tld/robots.txt file.
58
59
= WordPress 3+ in Multi Site mode =
60
64
65
The plugin works best from the **/mu-plugins/** folder where it runs quietly in the background without bothering any blog owner with new options or the need for special knowledge of XML Sitemap submission. Just upload the complete package content to /mu-plugins/ and move the file xml-sitemap.php from the new /mu-plugins/xml-sitemap-feed/ to /mu-plugins/.
66
67
+ Installed alongside [WordPress MU Sitewide Tags Pages](http://wordpress.org/extend/plugins/wordpress-mu-sitewide-tags/), XML Sitemap Feed will **not** create a sitemap.xml nor change robots.txt for any tag blogs. This is done deliberately because they would be full of links outside the tags blogs own domain and subsequently ignored (or worse: penalised) by Google.
68
69
== Frequently Asked Questions ==
70
71
= How are the values for priority and changefreq calculated? =
72
73
+ The front page has a fixed priority of 100% (1.0). When your site has more posts than pages (you must be using WordPress for a blog), pages have a default priority of 40% (0.4) and posts have a default priority of 80% (0.8). If your site has more pages than posts (you must be using WordPress as CMS), pages have a default priority of 80% (0.8) and posts have a default priority of 40% (0.4).
74
75
+ Page and post priority can vary between 0% (0.0) and 100% (1.0). Page priority depends on the page level (decreasing 10% for each sub-level) and relative number of comments. Post priority depends on relative number of comments and relative last comment age or (when the post has no comments) last post modification age.
76
77
+ The changefreq of the front page is fixed to daily and calculated for pages and post to either daily, weekly, monthly or yearly depending on age and comment activity.
78
79
Dynamic pages like category pages, tag pages and archive pages are not listed in the XML Sitemap.
80
81
= Can I manipulate values for priority and changefreq? =
82
83
+ Yes and No. This plugin has no options page so there is no way to manually set the priority of urls in the sitemap. But there is automatic post priority calculation based on _post modifaction date_ and _comment activity_, that can either make post priority go to 100% (1.0) for posts with many and recent comments or 0% (0) for the oldest posts with no comments.
84
85
+ This feature can be used to your advantage: by re-saving your most important older posts from time to time, keeping the **lastmod date** fairly recent, you can ensure a priority of at least 80% (0.8) for those URLs. And if you have comments on on those pages, the priority will even go up to 90% (0.9).
86
87
+ If you cannot live with these rules, edit the values `$min_priority`, `$max_priority` and `$frontpage_priority` in xml-sitemap-feed/feed-sitemap.php
88
89
= Do I need to submit the sitemap to search engines? =
90
106
107
2. 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 on the agenda of the major search engines, they will likely give no priority to your pings at all.
108
109
+ You can always take a [Google Webmaster Tools account](https://www.google.com/webmasters/tools/) which will tell you many interesting things about your website, sitemap downloads, search terms and your visitors. Try it!
110
111
= Do I need to change my robots.txt? =
112
113
That depends. In normal circumstances, if you have no physical robots.txt file in your site root, the new sitemap url will be automatically added to the dynamic robots.txt that is generated by WordPress. But in some cases this might not be the case.
114
115
+ If you use a static robots.txt file in your website root, you will need to open it in a text editor. If there is already a line with `Sitemap: http://yourblogurl.tld/sitemap.xml` you can just leave it like it is. But if there is no sitemap referrence there, add a line like `Sitemap: http://yourblogurl.tld/feed/sitemap/` (adapt to your site url) to make search engines find your XML Sitemap.
116
117
Or if you have WP installed in a subdirectory, on a server without rewrite_rules or if you do not use fancy URLs in your Permalink structure settings. In these cases, WordPress will need a little help in getting ready for XML Sitemap indexing. Read on in the **WordPress** section for more.
118
120
121
That depends on where the index.php and .htaccess of your installation resides. If it is in the root, meaning WP is installed in a subdir but the blog is accessible from your domain root, you do not have to do anything. It should work out of the box. However, if the index.php is (e.g. still with your wp-config.php and all other WP files) in a subdir, meaning your blog is only accessible via that subdir, you need to manage your own robots.txt file in your domain root. It _has_ to be in the root (!) and needs a line starting with `Sitemap:` followed by the full URL to the sitemap feed provided by XML Sitemap Feed plugin. Like:
122
`
123
+ Sitemap: http://yourblogurl.tld/subdir/feed/sitemap/
124
`
125
126
+ If you already have a robots.txt file with another Sitemap referrence like it, you might want to read more about creating an XML Sitemap Index on [sitemaps.org](http://www.sitemaps.org/protocol.php#index) to be able to referrence both sitemaps.
127
128
= Do I need to use a fancy Permalink structure? =
129
136
User-agent: *
137
Allow: /
138
`
139
+ You can also choose to notify major search engines of your new XML sitemap manually. Start with getting a [Google Webmaster Tools account](https://www.google.com/webmasters/tools/) and submit your sitemap for the first time from there to enable tracking of sitemap downloads by Google! or head over to [XML-Sitemaps.com](http://www.xml-sitemaps.com/validate-xml-sitemap.html) and enter your sites sitemap URL.
140
141
= Can I change the sitemap name/URL? =
142
143
+ No. If you have fancy URL's turned ON in WordPress (Permalinks), the sitemap url that you manually submit to Google (if you are impatient) should be `yourblogurl.tld/feed/sitemap/` but if you have the Permalinks' Default option set the feed is only available via `yourblogurl.tld/?feed=sitemap`.
144
145
= Where can I customize the xml output? =
146
147
+ You may edit the XML output in `xml-sitemap-feed/feed-sitemap.php` but be careful not to break Sitemap protocol compliance. Read more on [Sitemaps XML format](http://www.sitemaps.org/protocol.php).
148
149
The stylesheet (to make the sitemap human readable) can be edited in `xml-sitemap-feed/sitemap.xsl.php`.
150
151
+ = I see no sitemap.xml file in my site root! =
152
+
153
+ The sitemap is dynamically generated just like a feed. There is no actual file created.
154
+
155
+ = I do see a sitemap.xml file in site root but it does not seem to get updated! =
156
+
157
+ You are most likely looking at a sitemap.xml file that has been created by you or another XML Sitemap plugin before you started using this plugin. Just remove it and let the plugin dynamically generate it just like a feed. There is no actual file created.
158
+
159
= I get a 404 page instead of both sitemap.xml and robots.txt! =
160
161
There are plugins like Event Calendar (at least v.3.2.beta2) known to mess with rewrite rules, causing problems with WordPress internal feeds and robots.txt generation and thus conflict with the XML Sitemap Feed plugin. Deactivate all plugins and see if you get a basic robots.txt file showing:
171
172
To get around this, you might either at least write one post and give it _Private_ status or alternatively create your own robots.txt file containing:
173
`
174
+ Sitemap: http://yourblogurl.tld/feed/sitemap/
175
176
User-agent: *
177
Allow: /
178
`
179
and upload it to your web root...
180
181
+ = Can I do a Network Activate on WP3.0 MS / Site Wide Activate on WPMU with this plugin ? =
182
+
183
+ Yes.
184
+
185
+ = Can I run this plugin from /mu-plugins/ on WP3.0 MS / WPMU ? =
186
187
Yes.
188
189
== Changelog ==
190
191
+ = 3.7 =
192
+ * massive changefreq calculation improvement
193
+ * further priority calulation improvement taking last comment date into account
194
+
195
= 3.6.1 =
196
* BUGFIX: wrong date calculation on blogs less than 1 year old
197
sitemap.xsl.php CHANGED
@@ -69,7 +69,7 @@ echo '<?xml version="1.0" encoding="UTF-8"?>
69
</table>
70
</div>
71
<div id="footer">
72
- Generated by <a href="http://4visions.nl/en/index.php?section=57" title="XML Sitemap Feed plugin for WordPress">XML Sitemap Feed <?php echo $_GET['v'] ?></a> running on <a href="http://wordpress.org/">WordPress</a>.
73
</div>
74
</body>
75
</html>
69
</table>
70
</div>
71
<div id="footer">
72
+ <strong>XML Sitemap</strong> generated by <a href="http://4visions.nl/en/index.php?section=57" title="XML Sitemap Feed plugin for WordPress">XML Sitemap Feed <?php echo $_GET['v'] ?></a> running on <a href="http://wordpress.org/">WordPress</a>.
73
</div>
74
</body>
75
</html>
xml-sitemap.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: XML Sitemap Feed
4
Plugin URI: http://4visions.nl/portfolio/wordpress-plugins/xml-sitemap-feed/
5
Description: Creates a feed that complies with the XML Sitemap protocol ready for indexing by Google, Yahoo, Bing, Ask and others.
6
- Version: 3.6.1
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
@@ -37,7 +37,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravan
37
-------------------- */
38
39
// set version
40
- define('XMLSF_VERSION','3.6.1');
41
42
// dir
43
$xmlsf_dir = dirname(__FILE__);
3
Plugin Name: XML Sitemap Feed
4
Plugin URI: http://4visions.nl/portfolio/wordpress-plugins/xml-sitemap-feed/
5
Description: Creates a feed that complies with the XML Sitemap protocol ready for indexing by Google, Yahoo, Bing, Ask and others.
6
+ Version: 3.7
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
37
-------------------- */
38
39
// set version
40
+ define('XMLSF_VERSION','3.7');
41
42
// dir
43
$xmlsf_dir = dirname(__FILE__);