Skip to content

Instantly share code, notes, and snippets.

@stkjj
Created December 16, 2020 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stkjj/85dac069a41e2025372c63abea8e327e to your computer and use it in GitHub Desktop.
Save stkjj/85dac069a41e2025372c63abea8e327e to your computer and use it in GitHub Desktop.
Load CF7 CSS and JS only on a per need base
add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );
function reregister_cf7_js() {
if ( is_page (array(1,'kontakt'))) {
if (function_exists( 'wpcf7_enqueue_scripts')) {
wpcf7_enqueue_scripts();
}
if (function_exists( 'wpcf7_enqueue_styles')) {
wpcf7_enqueue_styles();
}
}
}
add_action('wp_enqueue_scripts','reregister_cf7_js');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment