WordPress is based on the so-called Hook-System. This serves WordPress, and all extensions to involve functions in a certain place. The Hooks are not only to hook, but can also be used in custom extensions and thus create a better overview and offer additional interfaces for more possibilities to develop. Especially the second option is interesting when you create a theme, which aims to offer a variety of interfaces, or create a Plugin which can be expand by other authors or serve as a framework.
To use the possibility of the hooks, you can use the same function as WordPress (do_action()
), and you don’t have to create your own functions or methods.
In the following example function, which I put in the functions.php
of the theme, of my Footer my_footer()
will be a hook defined using the function do_action()
. This can now be used and the hook is possible from the outside.
function my_footer() {
do_action('my_footer');
}
I call the actual function in the template of the theme, in this case of course in the footer.php
of the themes, in the example just before the closing body tag.