WordPress Hooks Functions

About This Index
This page is the WordPress Hooks Functions index. Each row links to a full guide with syntax, three examples, and FAQs.
Learn what hooks are and how actions and filters differ on WordPress Hooks. Use this page when you need one function, such as add_action(), add_filter(), or apply_filters().
An action runs your code at a moment (add_action() and do_action()). A filter changes a value, and your function must return it (add_filter() and apply_filters()). Lower priority numbers run first, and the default is 10.
How to Call a Hooks Function
Most of the time you add hooks in functions.php. Here is one action and one filter side by side.
<?php
// Action: do something when the hook fires.
add_action( 'wp_footer', 'my_footer_note' );
// Filter: change a value, then return it.
add_filter( 'excerpt_length', 'my_excerpt_length' );
function my_footer_note() {
echo '<p>Thanks for visiting!</p>';
}
function my_excerpt_length( $length ) {
return 20;
} WordPress Hooks Functions Table
All function guides in this WordPress hooks series (6 tutorials). Start with add_action() and add_filter().
Actions
3 functionsRun code at a moment: attach it, fire it, or remove it.
| Function | Description | Tutorial |
|---|---|---|
add_action() | Run your function when an action hook fires (do something). | Read guide |
do_action() | Fire an action hook so every function added to it runs. | Read guide |
remove_action() | Unhook a function that was added with add_action(). | Read guide |
Filters
3 functionsChange a value: attach a filter, run the filters, or remove one.
| Function | Description | Tutorial |
|---|---|---|
add_filter() | Change a value when a filter hook runs. The function must return it. | Read guide |
apply_filters() | Pass a value through every filter on a hook and get the result back. | Read guide |
remove_filter() | Unhook a function that was added with add_filter(). | Read guide |
Frequently Asked Questions
Start with add_action()
Run your function when a WordPress action hook fires.
9 people found this page helpful
