ตัวอย่างโค้ดเพื่อปิดหรือเปลี่ยนการแสดงผลในธีม Plant
ที่มาของการแสดงผลอัตโนมัติ
ในธีม Plant นั้น จะมี Hook 2 แห่ง ทำการเรียกปลั๊กอินนี้ไปแสดงผลโดยอัตโนมัติ คือ
plant_end_entry_meta
สำหรับหน้ารายละเอียดเรื่อง (Single)plant_end_archive_meta
สำหรับการแสดงผลตามหมวดหมู่, แท็ก หรือ Archive แบบอื่นๆ โดยจะมี Hook ในรูปแบบของ content-card / content-list และ content-caption
โดยโค้ดที่สั่งให้เพิ่มการแสดงผลอัตโนมัติ อยู่ในธีม plant ไฟล์ /inc/seed-stat-pro.php
ดังนี้
if( function_exists( 'run_Seed_Stat' ) ){
add_action('plant_end_entry_meta', 'plant_add_stat'); add_action('plant_end_archive_meta', 'plant_add_stat');
function plant_add_stat() { echo do_shortcode('[s_stat]'); }}
หากต้องการปิดการแสดงผล
ให้เพิ่มโค้ด remove_action ดังนี้ ในไฟล์ functions.php
หรือใช้ปลั๊กอินเช่น Code Snippets
remove_action('plant_end_entry_meta', 'plant_add_stat');remove_action('plant_end_archive_meta', 'plant_add_stat');
หากต้องการแสดงผลแบบอื่น
สามารถเพิ่มช็อตโค้ด [s_stat]
ในที่ที่ต้องการได้เลย หรือเปลี่ยนการแสดงผล แต่ใช้ตำแหน่งเดิม ก็เช่น
add_action('plant_end_entry_meta', 'mytheme_add_stat');add_action('plant_end_archive_meta', 'mytheme_add_stat');
function mytheme_add_stat() { echo do_shortcode('[s_stat icon="graph" style="minimal-1k"]');}