为网站建立Sitemap可以有助搜索引擎收录,除了使用插件外,我们也可以使用以下方法进行手工制作。
- 在你的主题目录中,新建文件:sitemap.php。在其开始部分添加如下代码:
<?php
/*
Template Name: Sitemap Page
*/
?> - 把你的主题目录内的page.php的内容复制到上面的新建文件中。把其中的<?php the_content() ?>改为:
<ul>
<?php $post_archives = new wp_query(’showposts=1000′);
while ( $post_archives->have_posts() ) : $post_archives->the_post(); ?>
<li>
<span><a href=”<?php the_permalink() ?>” title=”<?php printf(__( ‘Permalink to %s’, ‘theme-name’ ), wp_specialchars( get_the_title(), 1 ) ) ?>” rel=”bookmark”><?php the_title(); ?></a></span>
</li>
<?php endwhile; ?>
</ul> - 然后在WordPress的后台新建页面,内容空白即可,在模板选择“Sitemap Page”则可。
[ 转载请注明 ] 本文来自:下一页工作室,永久链接:http://www.nextpage.cn/wordpress-%e9%9d%9e%e6%8f%92%e4%bb%b6%e5%bb%ba%e7%ab%8b-sitemapwordpress-%e9%9d%9e%e6%8f%92%e4%bb%b6%e5%bb%ba%e7%ab%8b-sitemap/
有 0 位朋友喜欢此文
