<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>wordpress Archives - CNERIS</title>
	<atom:link href="https://cneris.com/zh/tag/wordpress-zh/feed/" rel="self" type="application/rss+xml" />
	<link>https://cneris.com/zh/tag/wordpress-zh/</link>
	<description></description>
	<lastBuildDate>Tue, 29 Oct 2024 09:10:27 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>A PHP session was created by a session_start() function call. This interferes with REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.</title>
		<link>https://cneris.com/zh/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-3/</link>
					<comments>https://cneris.com/zh/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-3/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 29 Oct 2024 09:10:27 +0000</pubDate>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[专用服务器]]></category>
		<category><![CDATA[系统管理]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[PHP 会话]]></category>
		<category><![CDATA[session_start() 代码]]></category>
		<category><![CDATA[session_write_close()]]></category>
		<category><![CDATA[wordpress]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2682</guid>

					<description><![CDATA[<p>此错误是由于 session_start() 函数创建了 PHP 会话，干扰了 WordPress 中的 REST API 和 loopback 请求。要解决此问题： 定位 session_start() 代码 在主题或激活的插件中查找 session_start() 函数。它可能在主题的 functions.php 文件或自定义插件中。 在 session_start() 后添加 session_write_close() 确保在每次调用 session_start() 后、执行任何 HTTP 请求之前调用 session_write_close()。这将关闭会话，从而允许 REST API 正常工作。例如： session_start(); // 在此处编写您的代码 session_write_close(); 在 WordPress 中使用 init 钩子 如果 session_start() 需要放在 functions.php 中，确保将其包装在 init 钩子中，并使用 session_write_close()，如下所示： add_action(‘init’, function() { if (!session_id()) [...]</p>
<p>The post <a href="https://cneris.com/zh/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-3/">A PHP session was created by a session_start() function call. This interferes with REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.</a> appeared first on <a href="https://cneris.com/zh">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>此错误是由于 <code>session_start()</code> 函数创建了 PHP 会话，干扰了 WordPress 中的 REST API 和 loopback 请求。要解决此问题：<span id="more-2682"></span></p>
<ol>
<li><strong>定位 <code>session_start()</code> 代码</strong><br />
在主题或激活的插件中查找 <code>session_start()</code> 函数。它可能在主题的 <code>functions.php</code> 文件或自定义插件中。</li>
<li><strong>在 <code>session_start()</code> 后添加 <code>session_write_close()</code></strong><br />
确保在每次调用 <code>session_start()</code> 后、执行任何 HTTP 请求之前调用 <code>session_write_close()</code>。这将关闭会话，从而允许 REST API 正常工作。例如：</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="sticky top-9 md:top-[5.75rem]"></div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><span class="hljs-title function_ invoke__">session_start</span>();<br />
<span class="hljs-comment">// 在此处编写您的代码</span><br />
<span class="hljs-title function_ invoke__">session_write_close</span>();<br />
</code></div>
</div>
</li>
<li><strong>在 WordPress 中使用 <code>init</code> 钩子</strong><br />
如果 <code>session_start()</code> 需要放在 <code>functions.php</code> 中，确保将其包装在 <code>init</code> 钩子中，并使用 <code>session_write_close()</code>，如下所示：</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="sticky top-9 md:top-[5.75rem]"></div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><span class="hljs-title function_ invoke__">add_action</span>(<span class="hljs-string">'init'</span>, function() {<br />
    <span class="hljs-keyword">if</span> (!<span class="hljs-title function_ invoke__">session_id</span>()) {<br />
        <span class="hljs-title function_ invoke__">session_start</span>();<br />
        <span class="hljs-title function_ invoke__">session_write_close</span>();<br />
    }<br />
});</code></div>
</div>
</li>
</ol>
<p>The post <a href="https://cneris.com/zh/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-3/">A PHP session was created by a session_start() function call. This interferes with REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.</a> appeared first on <a href="https://cneris.com/zh">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/zh/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-3/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>在WordPress 如何让每个文章分类设置默认特色图片</title>
		<link>https://cneris.com/zh/%e5%9c%a8wordpress-%e5%a6%82%e4%bd%95%e8%ae%a9%e6%af%8f%e4%b8%aa%e6%96%87%e7%ab%a0%e5%88%86%e7%b1%bb%e8%ae%be%e7%bd%ae%e9%bb%98%e8%ae%a4%e7%89%b9%e8%89%b2%e5%9b%be%e7%89%87/</link>
					<comments>https://cneris.com/zh/%e5%9c%a8wordpress-%e5%a6%82%e4%bd%95%e8%ae%a9%e6%af%8f%e4%b8%aa%e6%96%87%e7%ab%a0%e5%88%86%e7%b1%bb%e8%ae%be%e7%bd%ae%e9%bb%98%e8%ae%a4%e7%89%b9%e8%89%b2%e5%9b%be%e7%89%87/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 29 Oct 2024 09:01:17 +0000</pubDate>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[专用服务器]]></category>
		<category><![CDATA[系统管理]]></category>
		<category><![CDATA[网络应用]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[文章分类]]></category>
		<category><![CDATA[添加代码片段]]></category>
		<category><![CDATA[默认特色图片]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2673</guid>

					<description><![CDATA[<p>在 WordPress 中，您可以通过在主题的 functions.php 文件中添加代码片段，为每个文章分类设置默认特色图片。此代码会检查文章是否已分配了特色图片；如果没有，则根据文章的分类设置一个默认图片。 根据分类分配默认特色图片的代码 打开主题的 functions.php 文件（最好在子主题中操作，以避免更新时丢失更改）。 添加以下代码，并用每个分类的默认图片 URL 替换示例 URL： function set_default_thumbnail($post_id) { if (has_post_thumbnail($post_id)) { return; }// 定义每个分类的默认图片 $default_images = [ ‘category-1’ =&gt; ‘https://your-site.com/wp-content/uploads/category-image1.jpg’, ‘category-2’ =&gt; ‘https://your-site.com/wp-content/uploads/category-image2.jpg’, ‘category-3’ =&gt; ‘https://your-site.com/wp-content/uploads/category-image3.jpg’, ]; // 获取文章分类 $categories = get_the_category($post_id); // 检查是否分配了分类，并查找匹配的默认图片 foreach ($categories as $category) { if (array_key_exists($category-&gt;slug, $default_images)) { $image_url = $default_images[$category-&gt;slug]; // [...]</p>
<p>The post <a href="https://cneris.com/zh/%e5%9c%a8wordpress-%e5%a6%82%e4%bd%95%e8%ae%a9%e6%af%8f%e4%b8%aa%e6%96%87%e7%ab%a0%e5%88%86%e7%b1%bb%e8%ae%be%e7%bd%ae%e9%bb%98%e8%ae%a4%e7%89%b9%e8%89%b2%e5%9b%be%e7%89%87/">在WordPress 如何让每个文章分类设置默认特色图片</a> appeared first on <a href="https://cneris.com/zh">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>在 WordPress 中，您可以通过在主题的 <code>functions.php</code> 文件中添加代码片段，为每个文章分类设置默认特色图片。此代码会检查文章是否已分配了特色图片；如果没有，则根据文章的分类设置一个默认图片。<span id="more-2673"></span></p>
<h4>根据分类分配默认特色图片的代码</h4>
<ol>
<li>打开主题的 <code>functions.php</code> 文件（最好在子主题中操作，以避免更新时丢失更改）。</li>
<li>添加以下代码，并用每个分类的默认图片 URL 替换示例 URL：</li>
</ol>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"></code></code>function set_default_thumbnail($post_id) {<br />
if (has_post_thumbnail($post_id)) {<br />
return;<br />
}<code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"></code></code>// 定义每个分类的默认图片<br />
$default_images = [<br />
&#8216;category-1&#8217; =&gt; &#8216;https://your-site.com/wp-content/uploads/category-image1.jpg&#8217;,<br />
&#8216;category-2&#8217; =&gt; &#8216;https://your-site.com/wp-content/uploads/category-image2.jpg&#8217;,<br />
&#8216;category-3&#8217; =&gt; &#8216;https://your-site.com/wp-content/uploads/category-image3.jpg&#8217;,<br />
];</p>
<p><code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"></code></code>// 获取文章分类<br />
$categories = get_the_category($post_id);</p>
<p><code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"></code></code>// 检查是否分配了分类，并查找匹配的默认图片<br />
foreach ($categories as $category) {<br />
if (array_key_exists($category-&gt;slug, $default_images)) {<br />
$image_url = $default_images[$category-&gt;slug];</p>
<p>// 下载图片并设置为特色图片<br />
$image_id = attach_image_from_url($image_url, $post_id);<br />
if ($image_id) {<br />
set_post_thumbnail($post_id, $image_id);<br />
}<br />
break;<br />
}<br />
}<br />
}<br />
add_action(&#8216;save_post&#8217;, &#8216;set_default_thumbnail&#8217;);</p>
<p><code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"></code></code>// 函数：从 URL 下载图片并附加到文章<br />
function attach_image_from_url($image_url, $post_id) {<br />
$upload_dir = wp_upload_dir();<br />
$image_data = file_get_contents($image_url);<br />
$filename = basename($image_url);</p>
<p><code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"></code></code>if (wp_mkdir_p($upload_dir[&#8216;path&#8217;])) {<br />
$file = $upload_dir[&#8216;path&#8217;] . &#8216;/&#8217; . $filename;<br />
} else {<br />
$file = $upload_dir[&#8216;basedir&#8217;] . &#8216;/&#8217; . $filename;<br />
}</p>
<p><code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"></code></code>file_put_contents($file, $image_data);</p>
<p><code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"></code></code>$wp_filetype = wp_check_filetype($filename, null);<br />
$attachment = [<br />
&#8216;post_mime_type&#8217; =&gt; $wp_filetype[&#8216;type&#8217;],<br />
&#8216;post_title&#8217; =&gt; sanitize_file_name($filename),<br />
&#8216;post_content&#8217; =&gt; &#8221;,<br />
&#8216;post_status&#8217; =&gt; &#8216;inherit&#8217;<br />
];</p>
<p><code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"></code></code>$attach_id = wp_insert_attachment($attachment, $file, $post_id);<br />
require_once(ABSPATH . &#8216;wp-admin/includes/image.php&#8217;);<br />
$attach_data = wp_generate_attachment_metadata($attach_id, $file);<br />
wp_update_attachment_metadata($attach_id, $attach_data);</p>
<p><code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"></code></code>return $attach_id;<br />
}</p>
<p><code class="!whitespace-pre hljs language-php"><br />
</code></p>
</div>
</div>
<h4>代码说明</h4>
<ul>
<li><strong><code>$default_images</code></strong>：使用分类别名作为键、图片 URL 作为值，定义每个分类的默认图片。</li>
<li><strong><code>set_default_thumbnail</code></strong>：当文章被保存时运行此函数。如果文章没有特色图片，它会找到 <code>$default_images</code> 中第一个匹配的分类并设置为特色图片。</li>
<li><strong><code>attach_image_from_url</code></strong>：此函数从 URL 下载图片并将其附加到文章，生成特色图片。</li>
</ul>
<p>此代码将根据文章的分类自动分配默认特色图片，适用于新文章或编辑的文章。</p>
<p><strong>注意</strong>：确保在开发环境中测试此代码，然后再在正式网站上实施，并用实际的默认图片 URL 替换示例 URL。</p>
<p>The post <a href="https://cneris.com/zh/%e5%9c%a8wordpress-%e5%a6%82%e4%bd%95%e8%ae%a9%e6%af%8f%e4%b8%aa%e6%96%87%e7%ab%a0%e5%88%86%e7%b1%bb%e8%ae%be%e7%bd%ae%e9%bb%98%e8%ae%a4%e7%89%b9%e8%89%b2%e5%9b%be%e7%89%87/">在WordPress 如何让每个文章分类设置默认特色图片</a> appeared first on <a href="https://cneris.com/zh">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/zh/%e5%9c%a8wordpress-%e5%a6%82%e4%bd%95%e8%ae%a9%e6%af%8f%e4%b8%aa%e6%96%87%e7%ab%a0%e5%88%86%e7%b1%bb%e8%ae%be%e7%bd%ae%e9%bb%98%e8%ae%a4%e7%89%b9%e8%89%b2%e5%9b%be%e7%89%87/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>如何在 WordPress 中使用 Forminator 表单的回答自动生成 PDF</title>
		<link>https://cneris.com/zh/%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e4%bd%bf%e7%94%a8-forminator-%e8%a1%a8%e5%8d%95%e7%9a%84%e5%9b%9e%e7%ad%94%e8%87%aa%e5%8a%a8%e7%94%9f%e6%88%90-pdf/</link>
					<comments>https://cneris.com/zh/%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e4%bd%bf%e7%94%a8-forminator-%e8%a1%a8%e5%8d%95%e7%9a%84%e5%9b%9e%e7%ad%94%e8%87%aa%e5%8a%a8%e7%94%9f%e6%88%90-pdf/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 26 Oct 2024 10:26:55 +0000</pubDate>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[网络应用]]></category>
		<category><![CDATA[forminator]]></category>
		<category><![CDATA[Forminator 表单]]></category>
		<category><![CDATA[PDF 生成功能]]></category>
		<category><![CDATA[PDF插件]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[zapier]]></category>
		<category><![CDATA[自动生成 PDF]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2555</guid>

					<description><![CDATA[<p>要在 WordPress 中使用 Forminator 表单的回答自动生成 PDF，请按照以下详细步骤操作： 安装 Forminator 并创建表单： 确保您的表单已在 Forminator 中配置，并包含您需要在 PDF 中显示的所有字段。 使用 PDF 插件或 Zapier 来创建 PDF： Forminator 本身不支持 PDF 生成功能，但您可以使用插件或外部工具实现。 WP PDF 插件：一个付费插件，可以从 WordPress 表单的回答中自动生成 PDF。 Zapier：将 Forminator 连接到 Zapier，将数据发送到 Google Docs 或 PDF 生成应用，例如 PDF Generator API。 自动生成 PDF： 设置自动化流程，使用户提交 Forminator 表单后，回答会自动发送至 PDF 生成工具，并生成并发送最终的文件。</p>
<p>The post <a href="https://cneris.com/zh/%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e4%bd%bf%e7%94%a8-forminator-%e8%a1%a8%e5%8d%95%e7%9a%84%e5%9b%9e%e7%ad%94%e8%87%aa%e5%8a%a8%e7%94%9f%e6%88%90-pdf/">如何在 WordPress 中使用 Forminator 表单的回答自动生成 PDF</a> appeared first on <a href="https://cneris.com/zh">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>要在 WordPress 中使用 Forminator 表单的回答自动生成 PDF，请按照以下详细步骤操作：<span id="more-2555"></span></p>
<ol>
<li><strong>安装 Forminator 并创建表单</strong>：
<ul>
<li>确保您的表单已在 Forminator 中配置，并包含您需要在 PDF 中显示的所有字段。</li>
</ul>
</li>
<li><strong>使用 PDF 插件或 Zapier 来创建 PDF</strong>： Forminator 本身不支持 PDF 生成功能，但您可以使用插件或外部工具实现。
<ul>
<li><strong>WP PDF 插件</strong>：一个付费插件，可以从 WordPress 表单的回答中自动生成 PDF。</li>
<li><strong>Zapier</strong>：将 Forminator 连接到 Zapier，将数据发送到 Google Docs 或 PDF 生成应用，例如 PDF Generator API。</li>
</ul>
</li>
<li><strong>自动生成 PDF</strong>： 设置自动化流程，使用户提交 Forminator 表单后，回答会自动发送至 PDF 生成工具，并生成并发送最终的文件。</li>
</ol>
<p>The post <a href="https://cneris.com/zh/%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e4%bd%bf%e7%94%a8-forminator-%e8%a1%a8%e5%8d%95%e7%9a%84%e5%9b%9e%e7%ad%94%e8%87%aa%e5%8a%a8%e7%94%9f%e6%88%90-pdf/">如何在 WordPress 中使用 Forminator 表单的回答自动生成 PDF</a> appeared first on <a href="https://cneris.com/zh">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/zh/%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e4%bd%bf%e7%94%a8-forminator-%e8%a1%a8%e5%8d%95%e7%9a%84%e5%9b%9e%e7%ad%94%e8%87%aa%e5%8a%a8%e7%94%9f%e6%88%90-pdf/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>如何在 WordPress 中更改数据库字符集</title>
		<link>https://cneris.com/zh/%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e6%9b%b4%e6%94%b9%e6%95%b0%e6%8d%ae%e5%ba%93%e5%ad%97%e7%ac%a6%e9%9b%86/</link>
					<comments>https://cneris.com/zh/%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e6%9b%b4%e6%94%b9%e6%95%b0%e6%8d%ae%e5%ba%93%e5%ad%97%e7%ac%a6%e9%9b%86/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sun, 20 Oct 2024 16:53:16 +0000</pubDate>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[系统管理]]></category>
		<category><![CDATA[utf8mb4]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[数据库字符集]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2521</guid>

					<description><![CDATA[<p>要在 WordPress 中更改数据库字符集，请按照以下步骤操作： 访问 wp-config.php 文件，该文件位于 WordPress 安装的根目录中。 查找以下行： php Copiar código define(‘DB_CHARSET’, ‘utf8mb4’); define(‘DB_COLLATE’, ”); 如果这些行不存在或设置为其他值，请将 DB_CHARSET 更改为 utf8mb4，这是支持特殊字符（包括中文）的推荐字符集。 DB_COLLATE 应留空，或设置为 utf8mb4_unicode_ci 以指定特定的排序规则。 保存更改，如果你在本地工作，请将文件上传回服务器。 这样，WordPress 将配置为使用 UTF-8 字符集，以确保正确显示特殊字符，如中文。</p>
<p>The post <a href="https://cneris.com/zh/%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e6%9b%b4%e6%94%b9%e6%95%b0%e6%8d%ae%e5%ba%93%e5%ad%97%e7%ac%a6%e9%9b%86/">如何在 WordPress 中更改数据库字符集</a> appeared first on <a href="https://cneris.com/zh">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>要在 WordPress 中更改数据库字符集，请按照以下步骤操作：<span id="more-2521"></span></p>
<ol>
<li><strong>访问 <code>wp-config.php</code> 文件</strong>，该文件位于 WordPress 安装的根目录中。</li>
<li>查找以下行：
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary">php</div>
<div class="sticky top-9 md:top-[5.75rem]">
<div class="absolute bottom-0 right-2 flex h-9 items-center">
<div class="flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary"><span class="" data-state="closed"><button class="flex gap-1 items-center py-1">Copiar código</button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><span class="hljs-title function_ invoke__">define</span>(<span class="hljs-string">'DB_CHARSET'</span>, <span class="hljs-string">'utf8mb4'</span>);<br />
<span class="hljs-title function_ invoke__">define</span>(<span class="hljs-string">'DB_COLLATE'</span>, <span class="hljs-string">''</span>);<br />
</code></div>
</div>
</li>
<li>如果这些行不存在或设置为其他值，请将 <strong><code>DB_CHARSET</code></strong> 更改为 <strong><code>utf8mb4</code></strong>，这是支持特殊字符（包括中文）的推荐字符集。 <strong><code>DB_COLLATE</code></strong> 应留空，或设置为 <strong><code>utf8mb4_unicode_ci</code></strong> 以指定特定的排序规则。</li>
<li>保存更改，如果你在本地工作，请将文件上传回服务器。</li>
</ol>
<p>这样，WordPress 将配置为使用 UTF-8 字符集，以确保正确显示特殊字符，如中文。</p>
<p>The post <a href="https://cneris.com/zh/%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e6%9b%b4%e6%94%b9%e6%95%b0%e6%8d%ae%e5%ba%93%e5%ad%97%e7%ac%a6%e9%9b%86/">如何在 WordPress 中更改数据库字符集</a> appeared first on <a href="https://cneris.com/zh">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/zh/%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e6%9b%b4%e6%94%b9%e6%95%b0%e6%8d%ae%e5%ba%93%e5%ad%97%e7%ac%a6%e9%9b%86/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
