ฉันได้สร้างประเภทโพสต์ที่กำหนดเองและฉันต้องการซ่อนเนื้อหา textarea หลักในหน้าเผยแพร่ / แก้ไข
เป็นไปได้ไหม ?
ขอบคุณ!
ฉันได้สร้างประเภทโพสต์ที่กำหนดเองและฉันต้องการซ่อนเนื้อหา textarea หลักในหน้าเผยแพร่ / แก้ไข
เป็นไปได้ไหม ?
ขอบคุณ!
คำตอบ:
ใช่ลบการสนับสนุนบรรณาธิการจากประเภทโพสต์ที่คุณกำหนดเอง
คุณสามารถทำได้สองวิธี
ตัวอย่าง:
$args = array(
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'has_archive' => true,
'supports' => array('title','author','thumbnail','excerpt','comments')
);
register_post_type('book',$args);
2. ใช้การสนับสนุน remove_post_type หากประเภทโพสต์ที่กำหนดเองไม่ได้ถูกกำหนดโดยรหัสของคุณ (เช่นปลั๊กอิน / ธีมอื่น ๆ ได้กำหนดประเภทโพสต์ที่กำหนดเอง)
ตัวอย่าง:
add_action('init', 'my_rem_editor_from_post_type');
function my_rem_editor_from_post_type() {
remove_post_type_support( <POST TYPE>, 'editor' );
}
เมื่อลงทะเบียนประเภทโพสต์ที่กำหนดเองของคุณไม่ได้ระบุการสนับสนุนสำหรับการแก้ไข
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
// on the supports param here you see no 'editor'
'supports' => array('title','author','thumbnail','excerpt','comments')
);
register_post_type('book',$args);
ข้อมูลเพิ่มเติมโปรดดูที่: อ้างอิงฟังก์ชั่น / ลงทะเบียนประเภทโพสต์
คุณยังสามารถตั้งค่า
'supports' => false
เพื่อหลีกเลี่ยงพฤติกรรมเริ่มต้น (ชื่อเรื่องและตัวแก้ไข)
หมายเหตุ: นี่สำหรับ 3.5 หรือมากกว่า
คุณสามารถลบออกหรือแก้ไขในผู้ดูแลระบบของโมดูลโพสต์
function mvandemar_remove_post_type_support() {
remove_post_type_support( 'post', 'title' );
remove_post_type_support( 'post', 'editor' );
}
add_action( 'init', 'mvandemar_remove_post_type_support' );