Created
July 25, 2017 08:26
-
-
Save georgejipa/e624387af38a9e89917663467383c90e to your computer and use it in GitHub Desktop.
shortcode embed static assets
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 enqueue_assets() { | |
if (!is_singular()) { | |
return; | |
} | |
$content = get_post_field('post_content', get_the_ID()); | |
if (!has_shortcode($content, 'shortcode_name_here')) { | |
return; | |
} | |
wp_enqueue_script('contact_js', get_template_directory_uri() . '/assets/js/contact.js', array(), '1.1', true); | |
} | |
add_action('wp_enqueue_scripts', 'enqueue_assets'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment