How to remove Scripts section from Pages of a specific Page Template in Genesis

In the comments section of The Comprehensive Guide to Genesis Theme Supports, a user asked:

how can I remove the inpost scripts for a certain page template?

Adding the following in child theme’s functions.php will make Scripts section to not appear for static Pages to which page_products.php template has been applied.

add_action( 'init', 'custom_remove_scripts', 11 );
/**
 * Remove Scripts section from Pages of a specific Page Template.
 */
function custom_remove_scripts() {
    if ( ! isset( $_GET['post'] ) ) {
        return;
    }

    $template_file = get_post_meta( $_GET['post'], '_wp_page_template', true );

    if ( 'page_products.php' === $template_file ) { // replace `page_products.php` with name of your template.
        remove_post_type_support( 'page', 'genesis-scripts' );
    }
}
This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.