Contact Form only Loads On Contact page
-
Hi,
I think its stupid that contact form 7 JS and CSS loads on every page of the site, so I found some code that enables me to have it only load on the contact us page (see below).
It asks that I put this code in the functions.php file, however when I open it there is a wanring about editing the file.
So my question is, what’s the best way to implement this? Can i just put it in the functions.php? Do i need to add a child theme? if so how do i do that, and will i need to start my site design from scratch?
Thanks in advance for any help.
add_filter( ‘wpcf7_load_js’, ‘__return_false’ ); // Disable CF7 JavaScript
add_filter( ‘wpcf7_load_css’, ‘__return_false’ ); // Disable CF7 CSS
add_action(‘wp_enqueue_scripts’, ‘load_wpcf7_scripts’);
function load_wpcf7_scripts() {
if ( is_page(‘contact’) ) {
if ( function_exists( ‘wpcf7_enqueue_scripts’ ) ) {
wpcf7_enqueue_scripts();
}
if ( function_exists( ‘wpcf7_enqueue_styles’ ) ) {
wpcf7_enqueue_styles();
}
}
}
- The topic ‘Contact Form only Loads On Contact page’ is closed to new replies.