Posted By

robnilas on 01/21/17


Tagged


Versions (?)

Include JavaScript and CSS in Your WordPress


 / Published in: Other
 

  1. function wptuts_scripts_basic()
  2. {
  3. // Register the script like this for a plugin:
  4. wp_register_script( 'custom-script', plugins_url( '/js/custom-script.js', __FILE__ ) );
  5. // or
  6. // Register the script like this for a theme:
  7. wp_register_script( 'custom-script', get_template_directory_uri() . '/js/custom-script.js' );
  8.  
  9. // For either a plugin or a theme, you can then enqueue the script:
  10. wp_enqueue_script( 'custom-script' );
  11. }
  12. add_action( 'wp_enqueue_scripts', 'wptuts_scripts_basic' );

Report this snippet  

You need to login to post a comment.