相信不少数站长都是用插件实现HTML站点地图,分享下非插件实现站点地图.
HTML站点地图
一、新建一个sitemap.php文件,打开php文件粘贴以下代码:
- <?php
- /**
- @package WordPress
- Template Name: 站点地图
- */
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head profile="http://gmpg.org/xfn/11">
- <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" />
- <title>站点地图 – <?php bloginfo('name'); ?></title>
- <link rel="canonical" href="<?php echo get_permalink(); ?>" />
- <style type="text/css">
- body {
- FONT-SIZE: 14px;
- MARGIN: 0;
- color: #000000;
- background: rgba(255, 0, 0, 0);
- background-image:url("");
- background-repeat:repeat;
- background-size: 100% 100%;
- background-attachment:fixed
- }
- img {
- border: 0;
- }
- a {
- color: #2196f3;
- }
- li {
- margin-top: 8px;
- }
- .page {
- padding: 4px;
- border-top: 1px #EEEEEE solid
- }
- .author {
- background-color: #EEEEFF;
- padding: 6px;
- border-top: 1px #3f51b5 solid
- }
- #nav, #content, #footer {
- padding: 10px;
- border: 4px double #00bcd4;
- clear: both;
- width: 80%;
- margin: auto;
- margin-top: 10px;
- }
- </style>
- </head>
- <body vlink="#333333" link="#333333">
- <h2 style="text-align: center; margin-top: 20px"><?php bloginfo('name'); ?>站点地图</h2>
- <center></center>
- <div id="nav"><a href="<?php bloginfo('url'); ?>/"><strong><?php bloginfo('name'); ?></strong></a> » <a href="<?php echo get_permalink(); ?>">站点地图</a></div>
- <div id="content">
- <h3>文章</h3>
- <ul>
- <?php
- $previous_year = $year = 0;
- $previous_month = $month = 0;
- $ul_open = false;
- $myposts = get_posts('numberposts=-1&orderby=post_date&order=DESC');
- foreach($myposts as $post) :
- ?>
- <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" target="_blank"><?php the_title(); ?></a></li>
- <?php endforeach; ?>
- </ul>
- </div>
- <div id="content">
- <li class="categories">分类<ul>
- <?php wp_list_categories('title_li='); ?>
- </ul></li>
- </div>
- <div id="content">
- <li class="categories">页面</li>
- <?php wp_page_menu( $args ); ?>
- </div>
- <div id="footer">网站首页: <strong><a href="<?php bloginfo('url'); ?>/"><?php bloginfo('name'); ?></a></strong></div><br />
- <center>
- <div style="text-algin: center; font-size: 13px">Chiser丶</div>
- <div style="text-algin: center; font-size: 11px">最后更新:<?php $last = $wpdb->get_results("SELECT MAX(post_modified) AS MAX_m FROM $wpdb->posts WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')");$last = date('Y-m-d G:i:s', strtotime($last[0]->MAX_m));echo $last; ?><br /><br /></div>
- </center>
- </body>
- </html>
二、保存上传至当前主题目录下的page文件夹,【即页面模板目录】;
三、新建页面,模板选择站点地图发布,修改网址为sitemap.html即可;
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。