This code answers the following question from a member of the Genesis community:
Question : Is there a remove_action I can add to a page template to remove the site’s background image on that layout?
Answer : Yes, there’s at least 2 ways to remove the background image based on what layout the page is loading.
The 1st solution enables you to remove the image using a custom function which checks the default layout via your child themes functions file. In the following example, the image is removed only on pages where a full width content layout option is set.
add_action( 'genesis_meta', 'remove_back' );
function remove_back() {
$site_layout = genesis_site_layout();
if ( 'full-width-content' === $site_layout ) {
remove_theme_support( 'custom-background' );
}
}
Swap out full-width-content
in the above code snippet with any of the following default layout options included in most Genesis child themes.
content-sidebar
sidebar-content
content-sidebar-sidebar
sidebar-sidebar-content
sidebar-content-sidebar
full-width-content
The 2nd solution enables you to add the code directly to a template file like your front_page.php or page_landing.php file :
remove_theme_support( 'custom-background' );
You can add the single line of code above to any template file included in the WordPress Template Hierarchy.
Leave a Reply