Strategy 3 removes all registered event callbacks. Using
remove_all_actions(), you are removing or unregistering every single pre-registered event (hook) callbacks. Using this approach, our code then is:
|* Posts Page (Home) template|
|* @package KnowTheCode|
|* @since 1.0.0|
|* @author hellofromTonya|
|* @link https://KnowTheCode.io|
|* @license GNU-2.0+|
|remove_all_actions( 'genesis_footer' );|
When to Use This Approach?
This approach ensures that all of the callbacks are unregistered. It ensures that any callbacks outside of Genesis are removed. Why is that important? It ensures there are no wonky or weird renderings in the browser from your theme or plugin.
Strategy 2 removed the defaults from the Genesis framework including the opening HTML
<footer class="site-footer">, the contents of the site footer, and the closing HTML
</footer> element. What if there are other callbacks registered to the same
genesis_footer event (hook)? Strategy 2 does not remove them. Aha, but Strategy 3 does.
This is the best strategy for the majority of your use cases. Why?
- It’s a single line of code
- Ensures that all site footer callbacks are removed
- It targets specifically the Posts’ Page by using the
- It’s clear as to your intent, which increases maintainability of the code.
What if I need it on another page?
If you want to remove the site footer say on the Front Page, you can create a
front-page.php file and copy this code into it. It’s a simple solution that is reusable.
You get WET when you swim. Stay DRY when you code.
Total Lab Runtime: 00:33:41