!
也想出现在这里? 联系我们
信息

WordPress网站地图

WordPress的网站地图(sitemap)代码文件使用方法:

一、在主题的根目录新建一个名为sitemap.php的文件,将下放的代码放入文件中保存:

<?php
/*
 Template Name: 网站地图
*/
$text_logo = b2_get_option('normal_main', 'text_logo');
$img_logo = b2_get_option('normal_main', 'img_logo');
?>
<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>
    <meta name="keywords" content="站点地图,<?php bloginfo('name'); ?>" />
    <meta name="copyright" content="<?php bloginfo('name'); ?>" />
    <link rel="canonical" href="<?php echo get_permalink(); ?>" />
    <style type="text/css">
        body {
            font-family: Microsoft Yahei, Verdana;
            font-size: 13px;
            margin: 0 auto;
            color: #000000;
            background: #ffffff;
            width: 990px;
            margin: 0 auto
        }
        a:link,
        a:visited {
            color: #000;
            text-decoration: none;
        }
        a:hover {
            color: #08d;
            text-decoration: none;
        }
        h1,
        h2,
        h3,
        h4,
        h5,
        h6 {
            font-weight: normal;
        }
        img {
            border: 0;
        }
        li {
            margin-top: 8px;
        }
        .page {
            padding: 4px;
            border-top: 1px #EEEEEE solid
        }
        .author {
            background-color: #EEEEFF;
            padding: 6px;
            border-top: 1px #ddddee solid
        }
        #nav,
        #content,
        #footer {
            padding: 8px;
            border: 1px solid #EEEEEE;
            clear: both;
            width: 95%;
            margin: auto;
            margin-top: 10px;
        }
        .login-logo {
            text-align: center;
        }
    </style>
</head>
<body vlink="#333333" link="#333333">
    <h1 class="sc-fznWOq kxKJMB sc-fzqBkg hNumnz">
        <font>
            <div class="login-logo" onclick="location.href = '<?php bloginfo('url') ?>'"><?php echo ($img_logo ? '<img src="' . $img_logo . '" />' : $text_logo); ?></div>
        </font>
    </h1>
    <center>
    </center>
    <div id="nav"><a href="<?php echo esc_url(home_url()); ?>/"><strong><?php bloginfo('name'); ?></strong></a> &raquo; <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&showposts=100&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="content">
        <h1><?php _e('所有话题', 'jinsom'); ?></h1>
        <ul>
            <?php wp_tag_cloud('number=2000'); ?>
        </ul>
    </div>
    <div id="content">
        <h1><?php echo '最新注册用户'; ?></h1>
        <ul>
            <?php
            
            $user_query = new WP_User_Query(array(
                'orderby' => 'registered',
                'order' => 'DESC',
                'count_total' => false,
                'number' => 100
            ));
            
            if (!empty($user_query->results)) {
                foreach ($user_query->results as $user) {
                    $user_data = get_userdata($user->ID);
                    echo '<li><a href="' . get_author_posts_url($user->ID) . '" title="' . $user_data->display_name . '" target="_blank">' . $user_data->display_name . '</a></li>';
                }
            }
            ?>
            <div id="footer">查看博客首页:
                <strong>
                    <a href="<?php echo esc_url(home_url()); ?>/"><?php bloginfo('name'); ?></a>
                </strong>
            </div>
            <br />
            <center>
                <div style="text-algin: center; font-size: 11px">Latest Update:
                    <?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>

 

 

二、后台编辑新建页面

1、以上完成之后,打开wordpress后台,页面->新建页面->模板选择->网站地图,保存页面。

2、打开(查看)这个页面,完成。

b>声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
WordPressWordPress美化

WordPress首页小工具添加跑马灯公告

2023-4-3 14:07:03

WordPressWordPress美化

WordPress首页小工具添加跑马灯公告

2023-4-3 14:07:03

!
也想出现在这里? 联系我们
信息
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索