美文网首页
从Typecho转回Wordpress遇到的问题及解决办法

从Typecho转回Wordpress遇到的问题及解决办法

作者: 西凉听风 | 来源:发表于2021-10-27 13:11 被阅读0次

    最近把这个没人访问的小站从Typecho转回了Wordpress,没啥特别的原因,只是换了主机想折腾折腾。Typecho很优秀,但一直没更新,给人感觉没人在维护了(刚发现好像马上要出新版了)。

    自己所学所做和IT行业半毛钱关系没有,属纯外行。为了整个过程顺利省心,直接从腾讯云后台一键安装了Wordpress。整个过程很顺利,但也出现了一些小问题,下面做个记录以备下次折腾。

    1、 如何从typecho导入Wordpress

    2、PHP报错

    • 安装主题后,发现有些文章前会莫明其妙的出现有PHP错误代码。从网上找到了万能解决方法:在 functions.php (或 fun.php) 中<?php后面加入以下代码,完美解决:

    error_reporting(0);

    3、修改管理员邮箱和用户邮箱时,无法收到确认邮件的问题

    • 详见:WP-WordPress 收不到邮件的解决方法

    • 原因:各大主机服务商出于避免垃圾邮件的考虑,不支持发送邮件的 mail () 函数,只能启用 SMTP 方式发送邮件。

    • 解决办法:安装WP Mail SMTP插件,用163邮箱的SMTP设置成功

    4、wordpress 开启 https 后台登录无反应问题

    • 因为腾讯云需要备案,备案期间域名无法访问。在此期间,直接用公网ip登录Wordpress后台做各种转移和装修工作。腾讯云后台设置好HTTPS后,出现了这个后台登录无反应问题的问题。解决办法详见:wordpress、帝国 cms 网站配置 https(SSL) 无法登录后台

    1)、打开网站根目录文件 \ wp-includes\functions.php,找到代码 require(ABSPATH . WPINC . '/option.php'); 大概在第 8 行。

    在下方添加以下代码:

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n19" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: inherit inherit; background-repeat: inherit inherit;">add_filter('script_loader_src', 'agnostic_script_loader_src', 20,2); function agnostic_script_loader_src($src, $handle) { return preg_replace('/^(http|https):/', '', $src); } add_filter('style_loader_src', 'agnostic_style_loader_src', 20,2); function agnostic_style_loader_src($src, $handle) { return preg_replace('/^(http|https):/', '', $src); }
    
    </pre>
    

    2)、打开网站根目录 \ wp-config.php 文件找到代码

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n21" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: inherit inherit; background-repeat: inherit inherit;">*
    * @package WordPress
    */</pre>
    

    在下方添加如下代码:

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n23" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: inherit inherit; background-repeat: inherit inherit;">$_SERVER['HTTPS'] = 'on';
    define('FORCE_SSL_LOGIN', true);
    define('FORCE_SSL_ADMIN', true);</pre>
    

    完成以上两步操作后,可以正常访问 wordpress https 开头网站后台了,登录 wordpress 后台,点击设置 - 常规 - 常规选项,将 WordPress 地址 (URL)、站点地址(URL) 改为 https:// 开头的链接地址(如 https://www.aceact.com), 后点击“保存更改”。

    5、设置好CDN后,网页内容不能实时更新

    • 安装完CDN后,WordPress网站全站CDN缓存.。发布或更新文章、提交评论或评论被审核通过时,服务器并不能自动刷新CDN缓存。这样会造成网站内容不能及时更新,别人看到的网页可能还是CDN服务器提供的老的网页。要解决这个问题,可以在腾讯云后对手动刷新CDN缓存。但更简单的办法是安装CDN缓存插件,比如tencentcloud-cdn或者zhanzhangb-tcdn。

    6、免费图床哪家好

    原文见:XQRP.COM

    相关文章

      网友评论

          本文标题:从Typecho转回Wordpress遇到的问题及解决办法

          本文链接:https://www.haomeiwen.com/subject/itfpaltx.html