Tutorial by Examples

add_action( 'init', function() { // do something here } ); Using a function block to hook a set of instructions. With the init hook, the set of instructions will be executed right after wordpress has finished loading the necessary components.
function my_init_function() { // do something here } add_action( 'init', 'my_init_function' ); Using the name of the function to hook a set of instructions. With the init hook, the set of instructions will be executed right after wordpress has finished loading the necessary components. ...
class MyClass { static function my_init_method() { // do something here } } add_action( 'init', array( 'MyClass', 'my_init_method' ) ); Using a static method of a class to hook a set of instructions. With the init hook, the set of instructions will be executed right after w...
class MyClass { function my_init_method() { // do something here } } $obj = new MyClass(); add_action( 'init', array( $obj, 'my_init_method' ) ); Using a method of an object to hook a set of instructions. With the init hook, the set of instructions will be executed right...

Page 1 of 1