Last active
August 29, 2015 14:14
-
-
Save samkent/a418f98f1ea91407e098 to your computer and use it in GitHub Desktop.
WordPress Contact Form 7 only enqueue if page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Contact Form 7 only enqueue if page | |
* | |
* @author Sam Kent | |
* @link http://www.samkent.com | |
*/ | |
function contact_form_7_cleanup() { | |
// Dequeue scripts and styles | |
wp_dequeue_script( 'contact-form-7' ); | |
wp_dequeue_style( 'contact-form-7' ); | |
// Enqueue if page template | |
if ( is_page_template( 'contact.php' ) ) { | |
wp_enqueue_script( 'contact-form-7' ); | |
wp_enqueue_style( 'contact-form-7' ); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'contact_form_7_cleanup' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment