久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      WordPress怎么增加網(wǎng)站地圖

      下面由WordPress教程欄目給大家介紹WordPress增加網(wǎng)站地圖的方法,希望對(duì)需要的朋友有所幫助!

      WordPress怎么增加網(wǎng)站地圖

      先說(shuō)一句口號(hào):能用代碼解決的,堅(jiān)決不用插件!

      WordPress的網(wǎng)站地圖用一般的生成工具,生成之后都不能用,比如織夢(mèng)我常用sitemapx,結(jié)果放在WordPress就出錯(cuò)了。

      WordPress生成網(wǎng)站地圖的插件也有很多,大家可以自行百度,這里主要是講利用代碼生成。

      1.先將以下代碼將保存為 sitemap.php,傳到網(wǎng)站根目錄。

      <?php require('./wp-blog-header.php'); header("Content-type: text/xml"); header('HTTP/1.1 200 OK'); $posts_to_show = 1000;  echo '<?xml version="1.0" encoding="UTF-8"?>'; echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/">' ?> <!-- generated-on=<?php echo get_lastpostdate('blog'); ?> Diy By 獨(dú)立站大學(xué)(http://dulizhandaxue.com)-->   <url>       <loc><?php echo get_home_url(); ?></loc>       <lastmod><?php $ltime = get_lastpostmodified(GMT);$ltime = gmdate('Y-m-dTH:i:s+00:00', strtotime($ltime)); echo $ltime; ?></lastmod>       <changefreq>daily</changefreq>       <priority>1.0</priority>   </url> <?php /* 文章頁(yè)面 */  $myposts = get_posts( "numberposts=" . $posts_to_show ); foreach( $myposts as $post ) { ?>   <url>       <loc><?php the_permalink(); ?></loc>       <lastmod><?php the_time('c') ?></lastmod>       <changefreq>monthly</changefreq>       <priority>0.6</priority>   </url> <?php } /* 文章循環(huán)結(jié)束 */ ?>   <?php /* 單頁(yè)面 */  $mypages = get_pages(); if(count($mypages) > 0) {     foreach($mypages as $page) { ?>     <url>       <loc><?php echo get_page_link($page->ID); ?></loc>       <lastmod><?php echo str_replace(" ","T",get_page($page->ID)->post_modified); ?>+00:00</lastmod>       <changefreq>weekly</changefreq>       <priority>0.6</priority>   </url> <?php }} /* 單頁(yè)面循環(huán)結(jié)束 */ ?>  <?php /* 博客分類(lèi) */  $terms = get_terms('category', 'orderby=name&hide_empty=0' ); $count = count($terms); if($count > 0){ foreach ($terms as $term) { ?>     <url>       <loc><?php echo get_term_link($term, $term->slug); ?></loc>       <changefreq>weekly</changefreq>       <priority>0.8</priority>   </url> <?php }} /* 分類(lèi)循環(huán)結(jié)束 */?>  <?php  /* 標(biāo)簽(可選) */ $tags = get_terms("post_tag"); foreach ( $tags as $key => $tag ) { 	$link = get_term_link( intval($tag->term_id), "post_tag" ); 	     if ( is_wp_error( $link ) ) 		  return false; 		  $tags[ $key ]->link = $link; ?>  <url>       <loc><?php echo $link ?></loc>       <changefreq>monthly</changefreq>       <priority>0.4</priority>   </url> <?php  } /* 標(biāo)簽循環(huán)結(jié)束 */ ?>  </urlset>

      2.編輯 Nginx 偽靜態(tài)規(guī)則,新增如下規(guī)則:

      rewrite ^/sitemap.xml$ /sitemap.php last;

      3.編輯網(wǎng)站根目錄的.htaccess(如果沒(méi)有則新建為txt文檔),加入如下規(guī)則:

      RewriteRule ^(sitemap).xml$ $1.php

      直接訪問(wèn)網(wǎng)站域名+sitemap.xml即可。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)