{"id":33128,"date":"2024-11-25T12:07:37","date_gmt":"2024-11-25T04:07:37","guid":{"rendered":"https:\/\/fwq.ai\/blog\/33128\/"},"modified":"2024-11-25T12:07:37","modified_gmt":"2024-11-25T04:07:37","slug":"%e4%bc%98%e5%8c%96wordpress%e7%bd%91%e7%ab%99%ef%bc%8c%e6%b6%88%e9%99%a4%e4%b9%b1%e7%a0%81%e5%9b%b0%e6%89%b0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/33128\/","title":{"rendered":"\u4f18\u5316WordPress\u7f51\u7ad9\uff0c\u6d88\u9664\u4e71\u7801\u56f0\u6270"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/170963550434303.jpg\" class=\"aligncenter\" title=\"\u4f18\u5316WordPress\u7f51\u7ad9\uff0c\u6d88\u9664\u4e71\u7801\u56f0\u6270\u63d2\u56fe\" alt=\"\u4f18\u5316WordPress\u7f51\u7ad9\uff0c\u6d88\u9664\u4e71\u7801\u56f0\u6270\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f18\u5316WordPress\u7f51\u7ad9\uff0c\u6d88\u9664\u4e71\u7801\u56f0\u6270<\/strong><\/p>\n<p>\u5728\u5efa\u7acb\u548c\u7ba1\u7406WordPress\u7f51\u7ad9\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6709\u65f6\u5019\u4f1a\u9047\u5230\u4e71\u7801\u7684\u95ee\u9898\uff0c\u8fd9\u7ed9\u7528\u6237\u9605\u8bfb\u548c\u6d4f\u89c8\u7f51\u7ad9\u5e26\u6765\u4e86\u56f0\u6270\u3002\u4e71\u7801\u53ef\u80fd\u51fa\u73b0\u5728\u6587\u7ae0\u5185\u5bb9\u3001\u9875\u9762\u6807\u9898\u3001\u83dc\u5355\u680f\u7b49\u5404\u4e2a\u5730\u65b9\uff0c\u5f71\u54cd\u4e86\u7f51\u7ad9\u7684\u6574\u4f53\u7f8e\u89c2\u548c\u7528\u6237\u4f53\u9a8c\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u4e00\u4e9b\u65b9\u6cd5\u6765\u4f18\u5316WordPress\u7f51\u7ad9\uff0c\u6d88\u9664\u4e71\u7801\u95ee\u9898\uff0c\u540c\u65f6\u7ed9\u51fa\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<p><strong>\u4e00\u3001\u9009\u62e9\u5408\u9002\u7684\u5b57\u7b26\u96c6<\/strong><\/p>\n<p>\u5728WordPress\u4e2d\uff0c\u4f7f\u7528UTF-8\u5b57\u7b26\u96c6\u662f\u6700\u4e3a\u63a8\u8350\u7684\uff0c\u56e0\u4e3a\u5b83\u652f\u6301\u51e0\u4e4e\u6240\u6709\u7684\u8bed\u8a00\u548c\u5b57\u7b26\u3002\u786e\u4fdd\u5728WordPress\u8bbe\u7f6e\u4e2d\u9009\u62e9\u4e86\u6b63\u786e\u7684\u5b57\u7b26\u96c6\uff0c\u5728\u201c\u8bbe\u7f6e\u201d -&gt; \u201c\u901a\u7528\u201d\u4e2d\u53ef\u4ee5\u627e\u5230\u5b57\u7b26\u7f16\u7801\u9009\u9879\u3002<\/p>\n<pre>\/\/ \u8bbe\u7f6eWordPress\u5b57\u7b26\u7f16\u7801\u4e3aUTF-8\ndefine('DB_CHARSET', 'utf8');\ndefine('DB_COLLATE', '');<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u4e8c\u3001\u4fee\u6539\u6570\u636e\u5e93\u5b57\u7b26\u96c6<\/strong><\/p>\n<p>\u6709\u65f6\u5019\u4e71\u7801\u95ee\u9898\u53ef\u80fd\u6e90\u81ea\u6570\u636e\u5e93\u7684\u5b57\u7b26\u96c6\u8bbe\u7f6e\u4e0d\u6b63\u786e\u3002\u901a\u8fc7\u6570\u636e\u5e93\u7ba1\u7406\u5de5\u5177\uff08\u5982phpMyAdmin\uff09\u6765\u4fee\u6539\u6570\u636e\u5e93\u7684\u5b57\u7b26\u96c6\u4e3aUTF-8\uff0c\u53ef\u4ee5\u89e3\u51b3\u4e71\u7801\u95ee\u9898\u3002<\/p>\n<pre>ALTER DATABASE database_name DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u4e09\u3001\u5bf9WordPress\u4e3b\u9898\u8fdb\u884c\u4f18\u5316<\/strong><\/p>\n<p>\u5728\u4e3b\u9898\u7684functions.php\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff0c\u53ef\u4ee5\u4fee\u590d\u4e2d\u6587\u4e71\u7801\u95ee\u9898\uff0c\u786e\u4fdd\u4e2d\u6587\u5b57\u7b26\u6b63\u5e38\u663e\u793a\u3002<\/p>\n<pre>\/\/ \u907f\u514d\u5728\u8f93\u51fa\u6587\u672c\u4e2d\u81ea\u52a8\u8f6c\u6362\u4e3a\u5b57\u7b26\u7f16\u7801\nremove_filter('the_content', 'wptexturize');\nremove_filter('the_excerpt', 'wptexturize');\n\n\/\/ \u4fee\u590d\u4e2d\u6587\u4e71\u7801\u95ee\u9898\nadd_filter('the_content', 'convert_content');\nfunction convert_content($content) {\n    return htmlspecialchars($content, ENT_QUOTES, 'UTF-8');\n}\n\nadd_filter('the_title', 'convert_title');\nfunction convert_title($title) {\n    return htmlspecialchars($title, ENT_QUOTES, 'UTF-8');\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u56db\u3001\u8bbe\u7f6eHTTP\u54cd\u5e94\u5934<\/strong><\/p>\n<p>\u5728\u4e3b\u9898\u7684header.php\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff0c\u8bbe\u7f6eHTTP\u54cd\u5e94\u5934\u7684\u5b57\u7b26\u7f16\u7801\u3002<\/p>\n<pre>\/\/ \u8bbe\u7f6e\u5b57\u7b26\u7f16\u7801\u4e3aUTF-8\nheader('Content-Type: text\/html; charset=utf-8');<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u4e94\u3001\u4f7f\u7528\u63d2\u4ef6\u6765\u89e3\u51b3\u4e71\u7801\u95ee\u9898<\/strong><\/p>\n<p>\u6709\u4e9b\u63d2\u4ef6\u53ef\u4ee5\u5e2e\u52a9\u89e3\u51b3WordPress\u7f51\u7ad9\u7684\u4e71\u7801\u95ee\u9898\uff0c\u6bd4\u5982\u201cWP UTF-8 Sanitize\u201d\u63d2\u4ef6\uff0c\u53ef\u4ee5\u6e05\u7406\u4e0d\u6b63\u786e\u7684\u5b57\u7b26\u7f16\u7801\uff0c\u786e\u4fdd\u7f51\u7ad9\u5185\u5bb9\u663e\u793a\u6b63\u5e38\u3002<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u4f18\u5316WordPress\u7f51\u7ad9\uff0c\u6d88\u9664\u4e71\u7801\u95ee\u9898\uff0c\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u3002\u5e0c\u671b\u8fd9\u4e9b\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u80fd\u5e2e\u52a9\u60a8\u89e3\u51b3\u4e71\u7801\u56f0\u6270\uff0c\u8ba9\u60a8\u7684WordPress\u7f51\u7ad9\u66f4\u52a0\u7a33\u5b9a\u548c\u4e13\u4e1a\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f18\u5316WordPress\u7f51\u7ad9\uff0c\u6d88\u9664\u4e71\u7801\u56f0\u6270\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>\u4f18\u5316WordPress\u7f51\u7ad9\uff0c\u6d88\u9664\u4e71\u7801\u56f0\u6270 \u5728\u5efa\u7acb\u548c\u7ba1\u7406WordPress\u7f51\u7ad9\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6709\u65f6\u5019\u4f1a\u9047\u5230\u4e71\u7801\u7684\u95ee\u9898\uff0c\u8fd9\u7ed9\u7528\u6237\u9605\u8bfb\u548c\u6d4f\u89c8\u7f51\u7ad9\u5e26\u6765\u4e86\u56f0\u6270\u3002\u4e71\u7801\u53ef\u80fd\u51fa\u73b0\u5728\u6587\u7ae0\u5185\u5bb9\u3001\u9875\u9762\u6807\u9898\u3001\u83dc\u5355\u680f\u7b49\u5404\u4e2a\u5730\u65b9\uff0c\u5f71\u54cd\u4e86\u7f51\u7ad9\u7684\u6574\u4f53\u7f8e\u89c2\u548c\u7528\u6237\u4f53\u9a8c\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u4e00\u4e9b\u65b9\u6cd5\u6765\u4f18\u5316WordPress\u7f51\u7ad9\uff0c\u6d88\u9664\u4e71\u7801\u95ee\u9898\uff0c\u540c\u65f6\u7ed9\u51fa\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u3002 \u4e00\u3001\u9009\u62e9\u5408\u9002\u7684\u5b57\u7b26\u96c6 \u5728WordPress\u4e2d\uff0c\u4f7f\u7528UTF-8\u5b57\u7b26\u96c6\u662f\u6700\u4e3a\u63a8\u8350\u7684\uff0c\u56e0\u4e3a\u5b83\u652f\u6301\u51e0\u4e4e\u6240\u6709\u7684\u8bed\u8a00\u548c\u5b57\u7b26\u3002\u786e\u4fdd\u5728WordPress\u8bbe\u7f6e\u4e2d\u9009\u62e9\u4e86\u6b63\u786e\u7684\u5b57\u7b26\u96c6\uff0c\u5728\u201c\u8bbe\u7f6e\u201d -&gt; \u201c\u901a\u7528\u201d\u4e2d\u53ef\u4ee5\u627e\u5230\u5b57\u7b26\u7f16\u7801\u9009\u9879\u3002 \/\/ \u8bbe\u7f6eWordPress\u5b57\u7b26\u7f16\u7801\u4e3aUTF-8 define(&#8216;DB_CHARSET&#8217;, &#8216;utf8&#8217;); define(&#8216;DB_COLLATE&#8217;, &#8221;); \u767b\u5f55\u540e\u590d\u5236 \u4e8c\u3001\u4fee\u6539\u6570\u636e\u5e93\u5b57\u7b26\u96c6 \u6709\u65f6\u5019\u4e71\u7801\u95ee\u9898\u53ef\u80fd\u6e90\u81ea\u6570\u636e\u5e93\u7684\u5b57\u7b26\u96c6\u8bbe\u7f6e\u4e0d\u6b63\u786e\u3002\u901a\u8fc7\u6570\u636e\u5e93\u7ba1\u7406\u5de5\u5177\uff08\u5982phpMyAdmin\uff09\u6765\u4fee\u6539\u6570\u636e\u5e93\u7684\u5b57\u7b26\u96c6\u4e3aUTF-8\uff0c\u53ef\u4ee5\u89e3\u51b3\u4e71\u7801\u95ee\u9898\u3002 ALTER DATABASE database_name DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; \u767b\u5f55\u540e\u590d\u5236 \u4e09\u3001\u5bf9WordPress\u4e3b\u9898\u8fdb\u884c\u4f18\u5316 \u5728\u4e3b\u9898\u7684functions.php\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff0c\u53ef\u4ee5\u4fee\u590d\u4e2d\u6587\u4e71\u7801\u95ee\u9898\uff0c\u786e\u4fdd\u4e2d\u6587\u5b57\u7b26\u6b63\u5e38\u663e\u793a\u3002 \/\/ \u907f\u514d\u5728\u8f93\u51fa\u6587\u672c\u4e2d\u81ea\u52a8\u8f6c\u6362\u4e3a\u5b57\u7b26\u7f16\u7801 remove_filter(&#8216;the_content&#8217;, &#8216;wptexturize&#8217;); remove_filter(&#8216;the_excerpt&#8217;, &#8216;wptexturize&#8217;); \/\/ \u4fee\u590d\u4e2d\u6587\u4e71\u7801\u95ee\u9898 add_filter(&#8216;the_content&#8217;, &#8216;convert_content&#8217;); function convert_content($content) { return htmlspecialchars($content, ENT_QUOTES, &#8216;UTF-8&#8217;); } add_filter(&#8216;the_title&#8217;, &#8216;convert_title&#8217;); function convert_title($title) { return htmlspecialchars($title, ENT_QUOTES, &#8216;UTF-8&#8217;); } [&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-33128","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/33128","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=33128"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/33128\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=33128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=33128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=33128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}