WP Hook Creation
functions.php {Back end}
//A function named basicHook which have two parameters $a and $b.
function basicHook($a,$b){
echo "First Value : $a <br/>";
echo "Second Value : $b <br/>";
}
//Creating the hook :
1st parameter : hook name
2nd parameter : executing function
3rd parameter : executing priority
4th parameter : maximum number of parameters acceptance in the hook
add_action('ahook','basicHook',1,2);
header.php {Front end}
//Calling the hook from front end by the function named do_action();
1st parameter : defined hook name
2nd and 3rd parameter hook value.
do_action('ahook',500,600);
//A function named basicHook which have two parameters $a and $b.
function basicHook($a,$b){
echo "First Value : $a <br/>";
echo "Second Value : $b <br/>";
}
//Creating the hook :
1st parameter : hook name
2nd parameter : executing function
3rd parameter : executing priority
4th parameter : maximum number of parameters acceptance in the hook
add_action('ahook','basicHook',1,2);
header.php {Front end}
//Calling the hook from front end by the function named do_action();
1st parameter : defined hook name
2nd and 3rd parameter hook value.
do_action('ahook',500,600);
Comments
Post a Comment