{"id":31900,"date":"2024-11-25T09:47:33","date_gmt":"2024-11-25T01:47:33","guid":{"rendered":"https:\/\/fwq.ai\/blog\/31900\/"},"modified":"2024-11-25T09:47:33","modified_gmt":"2024-11-25T01:47:33","slug":"wordpress%e6%80%8e%e4%b9%88%e5%a2%9e%e5%8a%a0%e7%bd%91%e7%ab%99%e5%9c%b0%e5%9b%be","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/31900\/","title":{"rendered":"WordPress\u600e\u4e48\u589e\u52a0\u7f51\u7ad9\u5730\u56fe"},"content":{"rendered":"<p><span style=\"font-family:\">\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;<strong>WordPress\u6559\u7a0b<\/strong>\u680f\u76ee\u7ed9\u5927\u5bb6\u4ecb\u7ecdWordPress\u589e\u52a0\u7f51\u7ad9\u5730\u56fe\u7684\u65b9\u6cd5\uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01<\/span><\/p>\n<p><span style=\"font-family:\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/600698164287b903.jpg\" class=\"aligncenter\" title=\"WordPress\u600e\u4e48\u589e\u52a0\u7f51\u7ad9\u5730\u56fe\u63d2\u56fe\" alt=\"WordPress\u600e\u4e48\u589e\u52a0\u7f51\u7ad9\u5730\u56fe\u63d2\u56fe\" \/><\/span><\/p>\n<p><span style=\"font-family:\">\u5148\u8bf4\u4e00\u53e5\u53e3\u53f7\uff1a\u80fd\u7528\u4ee3\u7801\u89e3\u51b3\u7684\uff0c\u575a\u51b3\u4e0d\u7528\u63d2\u4ef6\uff01<\/span><\/p>\n<p>wordpress\u7684\u7f51\u7ad9\u5730\u56fe\u7528\u4e00\u822c\u7684\u751f\u6210\u5de5\u5177\uff0c\u751f\u6210\u4e4b\u540e\u90fd\u4e0d\u80fd\u7528\uff0c\u6bd4\u5982\u7ec7\u68a6\u6211\u5e38\u7528sitemapx\uff0c\u7ed3\u679c\u653e\u5728wordpress\u5c31\u51fa\u9519\u4e86\u3002<\/p>\n<p>WordPress\u751f\u6210\u7f51\u7ad9\u5730\u56fe\u7684\u63d2\u4ef6\u4e5f\u6709\u5f88\u591a\uff0c\u5927\u5bb6\u53ef\u4ee5\u81ea\u884c\u767e\u5ea6\uff0c\u8fd9\u91cc\u4e3b\u8981\u662f\u8bb2\u5229\u7528\u4ee3\u7801\u751f\u6210\u3002<\/p>\n<p>1.\u5148\u5c06\u4ee5\u4e0b\u4ee3\u7801\u5c06\u4fdd\u5b58\u4e3a sitemap.php\uff0c\u4f20\u5230\u7f51\u7ad9\u6839\u76ee\u5f55\u3002&nbsp;<\/p>\n<pre>&lt;?php require(&#039;.\/wp-blog-header.php&#039;);\nheader(\"Content-type: text\/xml\");\nheader(&#039;HTTP\/1.1 200 OK&#039;);\n$posts_to_show = 1000; \necho &#039;&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;';\necho&nbsp;'&lt;urlset&gt;'\n?&amp;gt;\n&lt;!-- generated-on=&lt;?php echo get_lastpostdate(&#039;blog&#039;); ?&gt; Diy By \u72ec\u7acb\u7ad9\u5927\u5b66(http:\/\/dulizhandaxue.com)--&gt;\n&nbsp;&nbsp;&lt;url&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;loc&gt;&lt;?php  echo get_home_url(); ?&gt;&lt;\/loc&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;lastmod&gt;&lt;?php  $ltime = get_lastpostmodified(GMT);$ltime = gmdate(&#039;Y-m-dTH:i:s+00:00&#039;, strtotime($ltime)); echo $ltime; ?&gt;&lt;\/lastmod&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;changefreq&gt;daily&lt;\/changefreq&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;priority&gt;1.0&lt;\/priority&gt;\n&nbsp;&nbsp;&lt;\/url&gt;&lt;?php \/* \u6587\u7ae0\u9875\u9762 *\/ \n$myposts = get_posts( \"numberposts=\" . $posts_to_show );\nforeach( $myposts as $post ) { ?&gt;\n&nbsp;&nbsp;&lt;url&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;loc&gt;&lt;?php  the_permalink(); ?&gt;&lt;\/loc&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;lastmod&gt;&lt;?php  the_time(&#039;c&#039;) ?&gt;&lt;\/lastmod&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;changefreq&gt;monthly&lt;\/changefreq&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;priority&gt;0.6&lt;\/priority&gt;\n&nbsp;&nbsp;&lt;\/url&gt;&lt;?php  } \/* \u6587\u7ae0\u5faa\u73af\u7ed3\u675f *\/ ?&gt;&nbsp;&nbsp;\n&lt;?php \/* \u5355\u9875\u9762 *\/ \n$mypages = get_pages();\nif(count($mypages) &gt;&nbsp;0)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;foreach($mypages&nbsp;as&nbsp;$page)&nbsp;{&nbsp;?&amp;gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;url&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;loc&gt;&lt;?php  echo get_page_link($page-&gt;ID);&nbsp;?&amp;gt;&lt;\/loc&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;lastmod&gt;&lt;?php  echo str_replace(\" \",\"T\",get_page($page-&gt;ID)-&amp;gt;post_modified);&nbsp;?&amp;gt;+00:00&lt;\/lastmod&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;changefreq&gt;weekly&lt;\/changefreq&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;priority&gt;0.6&lt;\/priority&gt;\n&nbsp;&nbsp;&lt;\/url&gt;&lt;?php  }} \/* \u5355\u9875\u9762\u5faa\u73af\u7ed3\u675f *\/ ?&gt;&nbsp;\n&lt;?php \/* \u535a\u5ba2\u5206\u7c7b *\/ \n$terms = get_terms(&#039;category&#039;, &#039;orderby=name&amp;hide_empty=0&#039; );\n$count = count($terms);\nif($count &gt;&nbsp;0){\nforeach&nbsp;($terms&nbsp;as&nbsp;$term)&nbsp;{&nbsp;?&amp;gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;url&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;loc&gt;&lt;?php  echo get_term_link($term, $term-&gt;slug);&nbsp;?&amp;gt;&lt;\/loc&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;changefreq&gt;weekly&lt;\/changefreq&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;priority&gt;0.8&lt;\/priority&gt;\n&nbsp;&nbsp;&lt;\/url&gt;&lt;?php  }} \/* \u5206\u7c7b\u5faa\u73af\u7ed3\u675f *\/?&gt;&nbsp;\n&lt;?php  \/* \u6807\u7b7e(\u53ef\u9009) *\/\n$tags = get_terms(\"post_tag\");\nforeach ( $tags as $key =&gt;&nbsp;$tag&nbsp;)&nbsp;{\n\t$link&nbsp;=&nbsp;get_term_link(&nbsp;intval($tag-&amp;gt;term_id),&nbsp;\"post_tag\"&nbsp;);\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(&nbsp;is_wp_error(&nbsp;$link&nbsp;)&nbsp;)\n\t\t&nbsp;&nbsp;return&nbsp;false;\n\t\t&nbsp;&nbsp;$tags[&nbsp;$key&nbsp;]-&amp;gt;link&nbsp;=&nbsp;$link;\n?&amp;gt;\n&nbsp;&lt;url&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;loc&gt;&lt;?php  echo $link ?&gt;&lt;\/loc&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;changefreq&gt;monthly&lt;\/changefreq&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;priority&gt;0.4&lt;\/priority&gt;\n&nbsp;&nbsp;&lt;\/url&gt;&lt;?php   } \/* \u6807\u7b7e\u5faa\u73af\u7ed3\u675f *\/ ?&gt;&nbsp;\n&lt;\/urlset&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>&nbsp;2.\u7f16\u8f91 Nginx \u4f2a\u9759\u6001\u89c4\u5219\uff0c\u65b0\u589e\u5982\u4e0b\u89c4\u5219\uff1a<\/p>\n<pre>rewrite&nbsp;^\/sitemap.xml$&nbsp;\/sitemap.php&nbsp;last;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>3.\u7f16\u8f91\u7f51\u7ad9\u6839\u76ee\u5f55\u7684.htaccess\uff08\u5982\u679c\u6ca1\u6709\u5219\u65b0\u5efa\u4e3atxt\u6587\u6863\uff09\uff0c\u52a0\u5165\u5982\u4e0b\u89c4\u5219\uff1a<\/p>\n<pre>RewriteRule&nbsp;^(sitemap).xml$&nbsp;$1.php<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u76f4\u63a5\u8bbf\u95ee\u7f51\u7ad9\u57df\u540d+sitemap.xml\u5373\u53ef\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fWordPress\u600e\u4e48\u589e\u52a0\u7f51\u7ad9\u5730\u56fe\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;WordPress\u6559\u7a0b\u680f\u76ee\u7ed9\u5927\u5bb6\u4ecb\u7ecdWordPress\u589e\u52a0\u7f51\u7ad9\u5730\u56fe\u7684\u65b9\u6cd5\uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01 \u5148\u8bf4\u4e00\u53e5\u53e3\u53f7\uff1a\u80fd\u7528\u4ee3\u7801\u89e3\u51b3\u7684\uff0c\u575a\u51b3\u4e0d\u7528\u63d2\u4ef6\uff01 wordpress\u7684\u7f51\u7ad9\u5730\u56fe\u7528\u4e00\u822c\u7684\u751f\u6210\u5de5\u5177\uff0c\u751f\u6210\u4e4b\u540e\u90fd\u4e0d\u80fd\u7528\uff0c\u6bd4\u5982\u7ec7\u68a6\u6211\u5e38\u7528sitemapx\uff0c\u7ed3\u679c\u653e\u5728wordpress\u5c31\u51fa\u9519\u4e86\u3002 WordPress\u751f\u6210\u7f51\u7ad9\u5730\u56fe\u7684\u63d2\u4ef6\u4e5f\u6709\u5f88\u591a\uff0c\u5927\u5bb6\u53ef\u4ee5\u81ea\u884c\u767e\u5ea6\uff0c\u8fd9\u91cc\u4e3b\u8981\u662f\u8bb2\u5229\u7528\u4ee3\u7801\u751f\u6210\u3002 1.\u5148\u5c06\u4ee5\u4e0b\u4ee3\u7801\u5c06\u4fdd\u5b58\u4e3a sitemap.php\uff0c\u4f20\u5230\u7f51\u7ad9\u6839\u76ee\u5f55\u3002&nbsp; &lt;?php require(&#039;.\/wp-blog-header.php&#039;); header(&#8220;Content-type: text\/xml&#8221;); header(&#039;HTTP\/1.1 200 OK&#039;); $posts_to_show = 1000; echo &#039;&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;&#8217;; echo&nbsp;&#8216;&lt;urlset&gt;&#8217; ?&amp;gt; &lt;!&#8211; generated-on=&lt;?php echo get_lastpostdate(&#039;blog&#039;); ?&gt; Diy By \u72ec\u7acb\u7ad9\u5927\u5b66(http:\/\/dulizhandaxue.com)&#8211;&gt; &nbsp;&nbsp;&lt;url&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;loc&gt;&lt;?php echo get_home_url(); ?&gt;&lt;\/loc&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;lastmod&gt;&lt;?php $ltime = get_lastpostmodified(GMT);$ltime = gmdate(&#039;Y-m-dTH:i:s+00:00&#039;, strtotime($ltime)); echo $ltime; ?&gt;&lt;\/lastmod&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;changefreq&gt;daily&lt;\/changefreq&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;priority&gt;1.0&lt;\/priority&gt; &nbsp;&nbsp;&lt;\/url&gt;&lt;?php \/* \u6587\u7ae0\u9875\u9762 *\/ $myposts = get_posts( [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-31900","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=31900"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31900\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=31900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=31900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=31900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}