Unlock your potential with a Pro Membership
Here is where you propel your career forward. Come join us today. Learn more.
Strategy 2: Remove the Individual Genesis Footer Actions
Lab: Remove the Genesis Site Footer on Home Page
Video Runtime: 05:30
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
to remove_action
.
Remember, 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.
The Code
After you’ve grabbed each of the callbacks in the Genesis framework, you’ll have the following home.php
template file:
<?php | |
/** | |
* 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' ); | |
genesis(); |
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.
Once upon a time, there was a developer... You! This is going to be a good story...
Episodes
Total Lab Runtime: 00:33:41
- 1 Lab Introductionfree 02:35
- 2 Strategy 1: Hide it with CSSfree 06:17
- 3 Strategy 2: Remove the Individual Genesis Footer Actionspro 05:30
- 4 Strategy 3: Remove All Genesis Footer Actionspro 03:09
- 5 Strategy 4: Reusable Functionpro 11:18
- 6 Which One to Use?pro 04:52