Hooks: Actions and Filters

What are hooks (actions and filters)? #

A hook is a piece of PHP code that allows overriding another piece of PHP code and extend or modify functionality. 

How to use Actions? #

Action hook is called in source code as: do_action( 'action_name' );

Use the next example to apply the action hook:

add_action( 'action_name', 'your_action_function_name' ); 
function your_action_function_name() {
// Your code
}

How to use Filters? #

Filter hook is called in source code as apply_filter( 'filter_name', $variable );

Use the next example to apply the filter hook:

add_filter( 'filter_name', 'your_filter_function_name' ); 
function your_filter_function_name( $variable ) {
// Your code returns the $variable;
}

Actions reference #

us_after_404 #

  • Located in: templates/404.php on line 102
  • Description: Fires after the default 404-page content

us_after_archive #

  • Located in: templates/archive.php on line 48
  • Description: Fires after archive page content

us_after_footer #

  • Located in: templates/footer.php on line 65
  • Description: Fires before footer content

Filters reference #

us_404_content #

  • Signature: apply_filters( 'us_404_content', $the_content );
  • Located in: templates/404.php on line 94
  • Description: Filters the default 404-page content
  • Params: $the_content

us_comment_form_fields #

  • Signature: apply_filters( 'us_comment_form_fields', $fields );
  • Located in: templates/comments.php on line 86
  • Description: Filters Comment Form fields
  • Params: $fields