Last active
September 11, 2016 00:22
-
-
Save danielpataki/d03c5ccc6bcd91cf0255ada4751b475e to your computer and use it in GitHub Desktop.
Enqueueing Scripts In WordPress
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
function my_enqueue($hook) { | |
if ( 'edit.php' != $hook ) { | |
return; | |
} | |
wp_enqueue_script( 'my_custom_script', plugin_dir_url( __FILE__ ) . 'myscript.js' ); | |
} | |
add_action( 'admin_enqueue_scripts', 'my_enqueue' ); |
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
function my_theme_scripts() { | |
wp_enqueue_script( 'my-script', get_template_directory_uri() . '/js/my-script.js', array( 'jquery' ), '1.0.0', true ); | |
} | |
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' ); |
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
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' ); | |
function my_theme_scripts() { | |
wp_register_script( 'my-carousel', get_template_directory_uri() . '/js/my-carousel.js', array( 'jquery' ), '1.0.0', true ); | |
} | |
add_shortcode('carousel', 'my_carousel'); | |
function my_carousel( $args ) { | |
$atts = shortcode_atts( array( | |
'ids' => '', | |
), $atts, 'carousel' ); | |
wp_enqueue_script('my-carousel'); | |
// Code to display carousel here | |
} |
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
function my_theme_scripts() { | |
if( is_category() ) { | |
wp_enqueue_script( 'my-script', get_template_directory_uri() . '/js/my-script.js', array( 'jquery' ), '1.0.0', true ); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' ); |
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
function my_theme_scripts() { | |
wp_enqueue_script( 'my-base-script', get_template_directory_uri() . '/js/my-base-script.js', array( 'jquery' ), '1.0.0', true ); | |
wp_enqueue_script( 'my-script-extension', get_template_directory_uri() . '/js/my-script-extension.js', array( 'my-base-script' ), '1.0.0', true ); | |
} | |
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' ); |
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
function my_theme_scripts() { | |
wp_deregister_script( 'jquery' ); | |
wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/jquery3.0.0.js', array(), '3.0.0', true ); | |
wp_enqueue_script( 'my-script', get_template_directory_uri() . '/js/my-script.js', array( 'jquery' ), '1.0.0', true ); | |
} | |
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' ); |
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
function my_theme_scripts() { | |
wp_register_script( 'my-script', get_template_directory_uri() . '/js/my-script.js', array( 'jquery' ), '1.0.0', true ); | |
wp_enqueue_script( 'my-script' ); | |
} | |
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi
can you tell me how to add schema script to the images?