Load scripts/styles only on one page
-
Is it possible with this plugin to ‘deregister’ the scripts on all pages except one? I am only using this plugin on one specific page and it seems pointless to load the scripts anywhere else. I know I have a similar code on my functions.php file for Contact Form 7, I’m just not quite sure what the proper syntax/reference names is for this plugin:
function deregister_cf7_js() { if ( !is_page('contact') ) { wp_deregister_script( 'contact-form-7' ); } } add_action( 'wp_print_scripts', 'deregister_cf7_js', 100 ); function deregister_ct7_styles() { wp_deregister_style( 'contact-form-7' ); } add_action( 'wp_print_styles', 'deregister_ct7_styles', 100 );
Any assistance you could offer would be greatly appreciated!
- The topic ‘Load scripts/styles only on one page’ is closed to new replies.