← Back to Course

Hooks: Actions and Filters

Modifying WordPress Without Editing Core

Hooks are the mechanism that let developers change WordPress's behaviour and output without touching any core files, keeping customisations update-safe.

Actions

Actions let you run custom code at a specific point in WordPress's execution, such as after a post is published or when the site footer loads.

You attach a function to an action using add_action(), specifying the hook name and your custom function.

Filters

Filters let you modify a piece of data before it's used or displayed, such as changing post content or excerpt length.

You attach a function to a filter using add_filter(), and your function must return the modified value.

Hook TypeWhat It DoesFunction Used
ActionRuns code at a specific pointadd_action()
FilterModifies data before it's usedadd_filter()

Hooks power a lot of custom functionality, including how WordPress exposes data externally through the REST API and shortcodes.

Ready to master WordPress Training Course?

Join Uncodemy's hands-on, mentor-led WordPress training and build real, live websites.

Explore Course