Skip to content

Instantly share code, notes, and snippets.

@mzalewski
Last active January 28, 2017 20:39
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 mzalewski/acc44c0498aea7ab85e4a06efd323365 to your computer and use it in GitHub Desktop.
Save mzalewski/acc44c0498aea7ab85e4a06efd323365 to your computer and use it in GitHub Desktop.
Adding scripts/styles to a WordPress plugin
<?php
function myplugin_enqueue_scripts() {
$plugin_url = plugin_dir_url( __FILE__ );
wp_enqueue_style( 'cssname', $plugin_url . 'assets/css.css', array(), '1.0' );
wp_enqueue_script( 'jsname', $plugin_url . 'assets/js.js', array( 'jquery' ), '1.0' );
}
add_action( 'wp_enqueue_scripts', 'myplugin_enqueue_scripts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment