PluginProbe ʕ •ᴥ•ʔ
XML Sitemap & Google News / 2.1
XML Sitemap & Google News v2.1
5.7.7 5.7.5 5.7.6 5.7.4 trunk 1.0 2.0 2.1 3.0 3.2 3.3 3.4 3.5 3.6.1 3.7.4 3.8.8 3.9.3 4.0.1 4.1.4 4.2.3 4.3.2 4.4.1 4.5.1 4.6.3 4.7.5 4.8.3 4.9.4 5.0.7 5.1.2 5.2.7 5.3.6 5.4.6 5.4.9 5.5.1 5.5.2 5.5.3 5.5.4 5.5.5 5.5.6 5.5.7 5.5.8 5.5.9 5.6 5.6.1 5.6.2 5.6.3 5.7 5.7.1 5.7.2 5.7.3
xml-sitemap-feed / template.php
xml-sitemap-feed Last commit date
readme.txt 16 years ago template.php 16 years ago xml-sitemap.php 16 years ago
template.php
72 lines
1 <?php
2 /**
3 * XML Sitemap Feed Template 2.1
4 **/
5
6 if (!empty($_SERVER['SCRIPT_FILENAME']) && 'feed-sitemap.php' == basename($_SERVER['SCRIPT_FILENAME']))
7 die ('Please do not load this page directly. Thanks!');
8
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/2.1" -->
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+00:00', $lastpostmodified, false); ?></lastmod>
29 <changefreq>daily</changefreq>
30 <priority>1.0</priority>
31 </url>
32 <?php
33
34 $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1000");
35
36 if ($post_ids) {
37 global $wp_query;
38 $wp_query->in_the_loop = true;
39
40 while ( $next_posts = array_splice($post_ids, 0, 20) ) {
41 $where = "WHERE ID IN (".join(',', $next_posts).")";
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+00:00', $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 }
70 } ?>
71 </urlset>
72