In Genesis Facebook group a user asks:
Good morning,
I could use some assistance. We have AgentPress Pro theme and would like to know is there a way to not display the footer from front page, and still have it be visible on every other page?Thank you in advance.
The relevant code that outputs the site footer is present in genesis/lib/structure/footer.php and it is:
add_action( 'genesis_footer', 'genesis_footer_markup_open', 5 );
add_action( 'genesis_footer', 'genesis_do_footer' );
add_action( 'genesis_footer', 'genesis_footer_markup_close', 15 );
We can change add_action
to remove_action
for the above lines in a function attached to a hook immediately above genesis_footer
(remember: hook as late as possible), that is genesis_before_footer
.
To ensure that the code only runs on the front page, we use this if conditional (remember: return early):
if ( ! is_front_page() ) {
return;
}
Putting it all together, add the following in child theme’s functions.php to get rid of the footer on just the homepage when using Genesis:
add_action( 'genesis_before_footer', 'custom_remove_footer_homepage' );
/**
* Remove site footer on homepage.
*/
function custom_remove_footer_homepage() {
// if this is not the homepage, abort.
if ( ! is_front_page() ) {
return;
}
remove_action( 'genesis_footer', 'genesis_footer_markup_open', 5 );
remove_action( 'genesis_footer', 'genesis_do_footer' );
remove_action( 'genesis_footer', 'genesis_footer_markup_close', 15 );
}