Actions

Last Updated:
Back to Main Index

Actions allow you to inject a custom function or bit of code into a specific place. You can create a custom Action using the main WordPress Action API to add or remove code from an existing core action by specifying any existing Hook. Thus the term “hooking.”

Layers also offers an Action API for hooking into our own custom actions.

For example: You may want to add code to the footer of Layers. This can be accomplished by writing new function containing your custom code, then Hooking it to the wp_footer core action OR use the Layers Action API to take advantage of better placement. The layers_before_footer_copyright action will output a custom element just above the copyright bar, for instance.

Custom Actions differ from custom Filters because custom Actions allow you to add or remove code from existing Actions. Whereas custom Filters allow you to replace specific data (such as a variable or CSS class) found within an existing Action.

From the WordPress Codex: