- Filter
โค้ด: เลือกทั้งหมด
add_filter( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )
$tag (string) (Required)
ชื่อ function หรือ ชื่อเหตุการณ์ที่จะเกิด เช่น the_content หมายความว่า ในส่วนของการจัดแสดง Content ในหน้าเว็บเราต้องการจะใส่อะไรเพื่อจะให้ WordPress แสดง
ศึกษารายละเอียด $tag ได้ที่ https://codex.wordpress.org/Plugin_API/Filter_Reference
$function_to_add (callable) (Required)
ชื่อของ function ที่เราจะเขียนเพื่อสั่งให้ทำงาน ตอนเหตุการณ์ที่เรา ระบุไว้เกิดขึ้น
ตัวอย่าง
ต้องการให้แสดงค่า
โค้ด: เลือกทั้งหมด
-------------------------> Show Hooks --->
โค้ด: เลือกทั้งหมด
add_filter( 'the_content', 'wptest_filterhook' );
function wptest_filterhook ( $content ) {
if ( is_single() ) {
$content .= '-------------------------> Show Hooks --->' . "";
}
return $content;
}
https://codex.wordpress.org/Plugin_API/Filter_Reference