آموزش رفع خطای XML declaration allowed در sitemap وردپرس

آموزش رفع خطای XML declaration allowed در sitemap وردپرس
آموزش رفع خطای XML declaration allowed در sitemap وردپرس

آموزش رفع خطای XML declaration allowed در sitemap وردپرس

اگر وب‌سایت شما در بخش sitemap خود خطای This page contains the following errors. error on line 1 at column 10: XML declaration allowed only at the start of the document. Below is a redering of the page up the first error را دریافت می‌کنید در این نوشته روش حل آن را می‌توانید مشاهده کنید.

 

آموزش رفع خطای XML declaration allowed در sitemap وردپرس

خطای XML declaration allowed در sitemap وردپرس

برای رفع این خطا وارد هاست سایت وردپرس خود شوید و در مسیر نصب وردپرس خود یک فایل با نام whitespacefix.php بسازید و قطعه کد زیر را درون آن قرار دهید:

<?php
function ___wejns_wp_whitespace_fix($input) {
    $allowed = false;
    $found = false;
    foreach (headers_list() as $header) {
        if (preg_match("/^content-type:\\s+(text\\/|application\\/((xhtml|atom|rss)\\+xml|xml))/i", $header)) {
            $allowed = true;
        }
 
        if (preg_match("/^content-type:\\s+/i", $header)) {
            $found = true;
        }
    }
 
    if ($allowed || !$found) {
        return preg_replace("/\\A\\s*/m", "", $input);
    } else {
        return $input;
    }
}
ob_start("___wejns_wp_whitespace_fix");
?>

سپس فایل index.php وردپرس خود را ویرایش کنید و قطعه کد زیر را در خط اول آن قرار دهید:

include('whitespacefix.php');

پایان.!

 

اگر نیاز به آموزش‌های بیشتری در ارتباط با وردپرس دارید در بخش نظرات همین نوشته برای ما بنویسید.

برای امتیاز به این نوشته کلیک کنید!
[کل: 2 میانگین: 5]