ตัวอย่างโค้ดเพื่อปิดหรือเปลี่ยนการแสดงผลในธีม Plant

ที่มาของการแสดงผลอัตโนมัติ

ในธีม Plant นั้น จะมี Hook 2 ที่ ที่ปลั๊กอินนี้แสดงผลโดยอัตโนมัติ คือ

  1. plant_end_entry_meta สำหรับหน้ารายละเอียดเรื่อง (Single)
  2. 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 หรือลงปลั๊กอินเช่น  My Custom Functions
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"]');
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us