最近幫人修改完網站之後,上傳到客户空間中,遇到了 WordPress 後台打開空白的問題。 WordPress 前台首頁正常。
網上搜的 WordPress 儀表盤空白的解決方案都是修改服務器上 wp-content/plugins 、 wp-content/themes 和 wp-content/uploads 文件夾的名字,如果修改名字之後,WordPress 後台可以打開的話,再一個個啓用 WordPress 插件,看是哪個插件影響了 WordPress 控制面板的打開。
其實關於 WordPress 後台空白問題的更直接的解決辦法是,打開 WordPress 網站根目錄的 wp-config.php,添加:
define(『WP_DEBUG』, true);
然後打開/wp-admin/,看網頁輸出了什麼錯誤提示。根據 WordPress 給出的錯誤提示,解決相關問題。
打開 wp_debug 之後,網站後台給出了 arning: Cannot modify header information – headers already sent by (output started at wp-config.php 的錯誤提示。
這表示 wp-config.php 中在<?php 之前或者最後的?> 之後有空行或者別的字符。用 notepad 編輯器打開 wp-config.php,格式設置為 utf8 without BOM,然後把<?php ?> 之前和之後多餘的字符、空行去掉。
把錯誤提示解決之後,WordPress 後台就可以正常打開了。
最後在 wp-config.php 中關閉 WP_DEBUG 。