Ashley Cameron Design

Ashley Cameron Design

Shop the Creative Design Market

Goodnight

Load Contact Form 7 only when needed

SnippetsWordPress

About a 1 minute read

"The art of living… is neither careless drifting on the one hand nor fearful clinging to the past on the other. It consists in being sensitive to each moment, in regarding it as utterly new and unique, in having the mind open and wholly receptive."

Alan Watts


1
2
3
4
5
6
7
add_action ('wp_print_scripts', 'my_deregister_cform', 100);

function my_deregister_cform() {
    if (!is_page_template('page-contact.php')) {
        wp_deregister_script('contact-form-7');
    }
}