WordPress hooks are importent part of WordPress devloper. Hooks are the core functionality of WordPress providing the ability to “hook into” your code in the wordpress code without modifying the core. Hooks basically calls a function to run at a specific time.

There are two type of hooks :
1) Action hook
2) Filter hook

Action hook is triggered at specific time when WordPress is running and lets you take an action in WordPress.
Filter hook allows you get and modify data before it is sent the browser or to the database .

Example of action hook :

Define action hook function :
function my_action_function() {
  wp_enqueue_script( 'my-javascript', 'my_js_code.js', false );
call action hook:
add_action( 'my_action_hook', 'my_action_function' );

Example of filter hook :

Define filter function :

function my_filter_function($code) {
  $code.='Your code edited';
  return $code;
call filter function :
add_filter( 'my_filter_hook', 'my_filter_function' );

Now how to display all hooks that run on current wordpress page

$debug= array();
add_action( 'all', function ( $tags ) {
    global $debug;
    if ( in_array( $tags, $debug ) ) {
    echo $tags ;
    $debug[] = $tags;
} );

Leave comment

Your email address will not be published. Required fields are marked with *.