Appendix A. WordPress Hook Reference

IN THIS APPENDIX

  • Using actions

  • Using filters

  • Hook reference: alphabetical listing

  • Hook reference: general uses

WordPress hooks are the lifeblood of WordPress and the developer ecosystem around it. They are what make WordPress truly extendable.

This appendix is a cheat sheet for developers to reference the 800+ hooks that are included in WordPress. You will find an alphabetical list of all hooks in WordPress 2.8 (Table A.1) and a breakdown of rough contexts that the hooks live in (Table A.2). Make sure you refer to the WordPress source code for exact usage.

Note

There is not enough room to cover how all these hooks work and it is expected that you are a developer who is familiar with the hook system and can find the usage in the WordPress code.

Note

Hooks, including multi-argument hooks, are discussed in greater detail in Chapter 5.

Using Actions

Actions are a type of hook that are fired when an event happens. With actions, developers can tie into an action hook with the add_action() function. Likewise, they can remove an already hooked function with remove_action(). The first argument in both of these cases is the hook name and the second is the name of the function being added to or removed from the hook.

In Listing A.1, I demonstrate how to use the add_action() function to attach a function to a hook. This function uses the Bit.ly URL shortener service (http://bit.ly) to create a shortened URL for a post when it is saved and adds it as a custom field called ...

Get WordPress® Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.