手机
当前位置:查字典教程网 >CMS教程 >WordPress >wordpress非插件实现xml格式网站地图
wordpress非插件实现xml格式网站地图
摘要:废话不多说,直接上代码';?>http://localhost/daily1.0monthly0.6复制上面代码为xmlmap.php文件并...

废话不多说,直接上代码

<?php

require('./wp-blog-header.php');

header("Content-type: text/xml");

header('HTTP/1.1 200 OK');

$posts_to_show = 1000; // 获取文章数量

echo '<?xml version="1.0" encoding="UTF-8"?>';

echo '<urlset xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance" rel="external nofollow" >http://www.w3.org/2001/XMLSchema-instance</a>" xmlns="<a href="http://www.sitemaps.org/schemas/sitemap/0.9" rel="external nofollow" rel="external nofollow" >http://www.sitemaps.org/schemas/sitemap/0.9</a>"

xsi:schemaLocation="<a href="http://www.sitemaps.org/schemas/sitemap/0.9" rel="external nofollow" rel="external nofollow" >http://www.sitemaps.org/schemas/sitemap/0.9</a> <a href="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'" rel="external nofollow" >http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'</a>;

?>

<>

<url>

<loc>http://localhost/</loc>

<lastmod><?php echo get_lastpostdate('blog'); ?></lastmod>

<changefreq>daily</changefreq>

<priority>1.0</priority>

</url>

<?php

header("Content-type: text/xml");

$myposts = get_posts( "numberposts=" . $posts_to_show );

foreach( $myposts as $post ) { ?>

<url>

<loc><?php the_permalink(); ?></loc>

<lastmod><?php the_time('c') ?></lastmod>

<changefreq>monthly</changefreq>

<priority>0.6</priority>

</url>

<?php } // end foreach ?>

</urlset>

复制上面代码为xmlmap.php文件并传至网站根目录

http://localhost/xmlmap.php

【wordpress非插件实现xml格式网站地图】相关文章:

Wordpress不用插件的SEO优化方法分享

wordpress固定链接翻译插件 自动将标题翻译成英文

Wordpress如何切换和管理网站外观

WordPress中非插件实现嵌套回复效果的方法

为Wordpress博客添加MP3播放器

WordPress中自动激活插件的实现方法

wordpress设置友情链接只在首页显示的方法

WordPress插件开发设计

wordpress恶意代码解决方法分享

WordPress评论邮件通知无插件实现思路及代码

精品推荐
分类导航