One of the most useful bits of functionality found in WordPress, as well as what makes Theme Frameworks like Freelancer so flexible, are the action hooks. Action Hooks are simply snippets of named code that allow you to “hook in” to their location. This means, for example, that you can create a custom PHP function and then hook it into various locations of your website based on where these hooks are located. It also means that Child Themes and Plugins can hook their functionality directly into the framework where they need to.
Let’s look at a basic example of how action hooks are setup in specific locations, and then how you might go about hooking into them. The following code shows a very basic HTML structure with a few action hooks being called in specific locations. Note that action hooks are named in such way as to indicate their specific location.
With the do_action code put in place by the theme framework you can then hook into them with add_action code like you see in the code below. Note that this is a simple custom function that could be added to your Child Theme’s functions.php file, for example, to echo the words “Hello World!” into a specific action hook location.
The result of the above code would be the text “Hello World!” displayed in the specific location of the specified hook, in this case being somewhere before the main content.