php - วิธีปรับขนาดคอลัมน์ของตารางผลิตภัณฑ์ผู้ดูแลระบบ WooCommerce

ฉันได้เพิ่มคอลัมน์พิเศษในรายการผลิตภัณฑ์ผู้ดูแลระบบ WooCommerce ของฉันแล้ว แต่คอลัมน์ไม่ได้รับการปรับตามค่า และฉันมีปัญหาต่อไปนี้


ฉันจะเปลี่ยน CSS ของตารางได้อย่างไร


table.fixed {
table-layout: fixed;
}

Answer

วิธีแก้ปัญหา:

add_action(\'admin_enqueue_scripts\', \'wc_product_list_css_overrides\');

function wc_product_list_css_overrides() {
wp_add_inline_style(\'woocommerce_admin_styles\',
"table.wp-list-table .column-sku{ width: 9%; } table.wp-list-table .column-name{ width: 20%; } table.wp-list-table .column-is_in_stock{ width: 7%; }");
}

โปรดใช้ชื่อคอลัมน์ที่เกี่ยวข้องและป้อนค่าความกว้างที่ต้องการ เช่น ตัวอย่างที่กำหนด


เพิ่มโค้ดด้านบนในไฟล์ functions.php ของธีมที่ใช้งานอยู่


Source