Conditionally load JS & CSS without special template
-
I’ve got this in my functions.php:
// Deregister CF7 script and style except where needed function mpb_disable_wpcf7() { if ( is_page( '1' ) || is_page( '2' ) || is_page( '3' ) ) { // change these to whatever pages or posts have a form on them } else { add_filter( 'wpcf7_load_js', '__return_false' ); add_filter( 'wpcf7_load_css', '__return_false' ); } } add_action( 'wp_head', 'mpb_disable_wpcf7' );
I supspect I need to use a different hook to get it to work, since CF7 still loads on all the pages.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Conditionally load JS & CSS without special template’ is closed to new replies.