Skip to content

Instantly share code, notes, and snippets.

@AntonioRigo
Last active November 9, 2016 12:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AntonioRigo/8dae44eb7ef063b5133d to your computer and use it in GitHub Desktop.
Save AntonioRigo/8dae44eb7ef063b5133d to your computer and use it in GitHub Desktop.
Añadir scripts a un child theme para WordPress
<?php
function enqueue_custom_scripts(){ // función para agregar scripts.
if ( !is_admin() ) { // instrucción para solo cargar el script si NO es el área de administración.
// registra la ubicación de tu script, sus dependencias, versión, y si quieres añadirlo al final del archivo.
wp_register_script( 'custom_script', get_bloginfo('stylesheet_directory') . '/js/custom_script.js', array( 'jquery' ), '1.0', true );
// agrega el script a la cola de carga.
wp_enqueue_script( 'custom_script' );
}
}
add_action( 'wp_enqueue_scripts', 'enqueue_custom_scripts' ); // hook que dispara la función para agregar scripts.
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment