Last active
March 2, 2021 19:08
-
-
Save perezdans/799a13d4aa4da7757b08d23271757d4e to your computer and use it in GitHub Desktop.
Código a incluir en el functions.php o en un plugin para evitar la carga del javascript de Contact Form 7 en todas las páginas y que se cargue únicamente en las páginas donde haya formulario
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
//Evitar la carga en todas las páginas | |
add_filter( ‘wpcf7_load_js’, ‘__return_false’ ); | |
add_filter( ‘wpcf7_load_css’, ‘__return_false’ ); | |
//Cargar solo en las que nos interesan | |
function jpd_carga_contactform7(){ | |
if ( is_page(‘contacto, inicio’) ) { | |
if ( function_exists( ‘wpcf7_enqueue_scripts’ ) ) { | |
wpcf7_enqueue_scripts(); | |
} | |
if ( function_exists( ‘wpcf7_enqueue_styles’ ) ) { | |
wpcf7_enqueue_styles(); | |
} | |
} | |
} | |
add_action( ‘wp_enqueue_scripts’, ‘jpd_carga_contactform7’ ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment