จะตั้งค่าให้ Wordpress เรียก JS กับ CSS ตัวอื่นแทนของเก่าของ Theme อย่างไรครับ

เริ่มโดย jampro, 18 ธันวาคม 2018, 17:29:09

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

jampro

คือผมต้องการประหยัด Bandwidth โดยอัพโหลด JS กับ CSS ไว้ใน dropbox แต่ไม่ทราบว่าจะเรียกมันมาใช้อย่างไรน่ะครับ

Theme ปกติเขาจะเขียนโค้ดเรียกไว้ตรงไหน แล้วเราต้องเข้าไปลบอะไรออก ใส่อะไรแทนบ้าง

สองตัวนี้นะครับ ที่ผมจะแก้
wp-content/themes/Newspaper/js/tagdiv_theme.js
wp-content/themes/Newspaper/style.css

ผมใช้ Newspaper นะครับ รบกวนขอคำแนะนำด้วยครับ :wanwan017:

host24plus

โดยปกติแล้ว wordpress จะเรียกไฟล์ css โดยอ้างอิงมาจากไฟล์ functions.php ของทีมนั้นๆ

ตัวอย่างโค้ด  wp_enqueue_style('host24plus-support', get_template_directory_uri() . '/css/xxxx.css');

สำหรับ JS ก็ประมาณนี้น่ะ
wp_enqueue_script('host24plus-support', get_template_directory_uri() . '/js/xxxxx.js', array(), null, true);

jampro

หา enqueue ใน functions ไม่เจอเลยครับ ดูไฟล์อื่นๆที่อยู่ใน Theme ก็ไม่เจอ :wanwan031:

bikinisoft

ปกติ ธีมที่ซื้อ จะมี child theme มาให้นะครับ (ถ้าไม่มีก็ลองหาวิธีทำ child theme ดูครับ)
ลองลง child theme ดู แล้วไปเรียกใช้ js และ css ในไฟล์ functions.php ของ child theme ได้ครับ
และ dequeue ของ parent theme ออกครับ ลองค้นหาคำนี้ wp_dequeue_script parent theme

ลองดูจากนี่ก็ได้ครับ https://codex.wordpress.org/Child_Themes
www.padatheme.com
www.shinery-jewelry.com