แก้ปัญหา WP SuperCache ขึ้น File name too long

หากพบปัญหา wp-supercache เกิด error เนื่องจาก URL permalink เป็นภาษาไทยยาวจน wp-supercache ไม่ทำงาน
การแก้ไขสามารถทำได้โดยสร้าง Plugin ให้กับ WP-SuperCache อีกที
โดยสร้างไฟล์ php ชื่ออะไรก็ได้

<?php
function iz_wpscfix_dir($uri) {
        $uris = explode('/', $uri);
        $result = array();
        foreach ($uris as $path) {
                if (strlen($path) > 250) {
                        $path = substr($path, 0, 220).'-'.md5($path);
                }
                $result[] = $path;
        }
        return implode("/",$result);
}
add_cacheaction('supercache_dir', 'iz_wpscfix_dir', 0);

จากนั้นเอาไปใส่ไว้ที่ wp-content/plugins/wp-super-cache/plugins/
แค่นี้ก็แก้ปัญหาเรียบร้อย ส่วน rewrite url มีปัญหาแล้วครับ

ขอบคุณเทคนิคดีๆ แบบนี้จากคุณ icez แห่ง THT ครับ

Was this article helpful?

Related Articles