首页CMSWordPress自定义网站地图模板页面 放弃自带的地图样式

WordPress自定义网站地图模板页面 放弃自带的地图样式

时间2024-05-22 21:50:03发布访客分类CMS浏览946
导读:由于可能大家的需要,我们在使用WordPress程序的时候会通过安装插件来实现网站地图的页面,但是我们要知道从5.5开始,WordPress有内置地图功能,我们只需要默认直接打开sitemap.xml既可以看到我们的默认地图文件,但是我们如...

由于可能大家的需要,我们在使用WordPress程序的时候会通过安装插件来实现网站地图的页面,但是我们要知道从5.5开始,WordPress有内置地图功能,我们只需要默认直接打开sitemap.xml既可以看到我们的默认地图文件,但是我们如果不喜欢这样的默认格式的话,我们也可以自定义设置地图模板。

?php/* Template Name: WP自定义地图*/?>
    !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>
    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;
}
    /style>
    /head>
    body vlink="#333333" link="#333333">
    h2 style="text-align: center;
     margin-top: 20px">
    ?php bloginfo('name');
     ?>
    's SiteMap /h2>
    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&
    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 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>
    

这里我们可以创建一个模板文件,比如sitemap.php,然后我们可以创建单独的页面,选择WP自定义地图模板。

然后我们可以看到自定义的地图页面,根据我们实际需要可以更换样式和界面体验前端。

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: WordPress自定义网站地图模板页面 放弃自带的地图样式
本文地址: https://pptw.com/jishu/665868.html
zookeeper配置集群的步骤是什么 div css 命名规则技巧

游客 回复需填写必要信息