WordPress加上站点地图

花了些时间整合了Blog的一些标签和tag,看上去应该干净了不少。

同时修改了一下主题,加大宽度。虽然很喜欢现在用的主题,但是却已经很古老了,里面用的一些WordPress内部函数都已经不被推荐继续采用,因此也都改为新的函数。顺便在侧栏也加上了Tag Cloud。

然后加上了一个Sitemap页面,里面是全站链接。

Sitemap的做成记录:

1、把正在用的主题(theme)中的page.php复制后重命名为sitemap.php,在文件的顶部加上:

<?php 
   /* 
   Template Name: Sitemap 
   */ 
?>

2、 在sitemap.php的

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php endwhile; endif; ?>

中间添加:

<h2><?php the_title(); ?></h2>
 
<h3>All internal pages:</h3>
<ul>
	<?php wp_list_pages('title_li='); ?>
</ul>
 
<h3>All internal blog posts:</h3>
<ul>
	<?php
	$lastposts = get_posts('numberposts=1000');
	foreach($lastposts as $post) :
	?>
	<li><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></li>
	<?php endforeach; ?>
</ul>
 
<h3>Monthly archive pages:</h3>
<ul>
	<?php wp_get_archives('type=monthly'); ?>
</ul>
 
<h3>Topical archive pages:</h3>
<ul>
	<?php wp_list_categories('title_li=0'); ?>
</ul>
 
<h3>Available RSS Feeds:</h3>
<ul>
	<li><a href="<?php bloginfo('rdf_url'); ?>" alt="RDF/RSS 1.0 feed"><acronym title="Resource Description Framework">RDF</acronym>/<acronym title="Really Simple Syndication">RSS</acronym> 1.0 feed</a></li>
	<li><a href="<?php bloginfo('rss_url'); ?>" alt="RSS 0.92 feed"><acronym title="Really Simple Syndication">RSS</acronym> 0.92 feed</a></li>
	<li><a href="<?php bloginfo('rss2_url'); ?>" alt="RSS 2.0 feed"><acronym title="Really Simple Syndication">RSS</acronym> 2.0 feed</a></li>
	<li><a href="<?php bloginfo('atom_url'); ?>" alt="Atom feed">Atom feed</a></li>
</ul>
 
<div class="clear rule"></div>

3、在后台建立一个Page,标题自定,slug可以写成sitemap,模板选择sitemap,然后发布就OK了。

6 Responses

Leave a Comment

(Necessary)

(Necessary, will not be published)

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.