Created
October 23, 2016 01:28
-
-
Save vladimirlukyanov/82200331941c74d56a8e24bcbed8e53c to your computer and use it in GitHub Desktop.
Shortcode style enqueue #4
This file contains hidden or 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
<?php | |
function custom_shortcode_scripts() { | |
global $post; | |
if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'myshortcode') ) { | |
wp_enqueue_script( 'my-script'); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'custom_shortcode_scripts'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment