Strategy 2 will remove the individual Genesis callbacks (hooks) for the site footer. It requires you to create a
home.php file in your child theme. This is the file that is called for the Posts’ Page. (If that doesn’t make sense, then you need to go do the Front Page vs. Home Page lab.)
Now inside of this new template file, this new PHP file, you will add the individual Genesis callbacks to unregister each of them. Let’s go into the Genesis framework and find each of the hooks. Open up
genesis/lib/structure/footer.php. Scroll down and find each of the site footer hooks. Copy each one into your
home.php file. Change the
add_action registers the callback to the specific event (hook) name. In this case, our event name is
genesis_footer. To remove these, you need to unregister the callbacks. WordPress gives you the
remove_action construct to unregister it.
To learn more about callbacks, events, and hooks, go do the Introduction & Registering Events (Hooks) lab.
After you’ve grabbed each of the callbacks in the Genesis framework, you’ll have the following
home.php template file:
|* Posts Page (Home) template|
|* @package KnowTheCode|
|* @since 1.0.0|
|* @author hellofromTonya|
|* @link https://KnowTheCode.io|
|* @license GNU-2.0+|
|remove_action( 'genesis_footer', 'genesis_footer_markup_open', 5 );|
|remove_action( 'genesis_footer', 'genesis_footer_markup_close', 15 );|
|remove_action( 'genesis_footer', 'genesis_do_footer' );|
When to Use This Strategy?
This strategy targets specifically the Posts Page, which is the home page. You created a template file in your theme. When WordPress runs, it calls this template file. Therefore, the code here only runs for just this specific page.
The only benefit to this approach is that it completely removes the site footer from the HTML markup of the web page. No styling is needed. Visually, it’s gone. For those who use screen readers, it’s gone too. Web crawlers won’t read it. Why? It’s not been built and sent out to the browser.
This is a good solution and better than the CSS strategy for the majority of the use cases.
The negative to this approach is that other callbacks from your child theme or plugins will not be removed. Therefore, you might be some weird or wonky behavior if this occurs. Why? You’ve only removed the 3 specific callbacks from the Genesis framework. That’s it. If another callback outside of Genesis is adding say a widget or other HTML, it will appear at the bottom of your website and look weird.
Don’t repeat yourself. Don’t repeat yourself. Don’t repeat yourself.
Total Lab Runtime: 00:33:41