Created
May 7, 2020 23:59
-
-
Save chris-castillo-dev/d0b686aa37d3be3282d2143a2d0ac7d5 to your computer and use it in GitHub Desktop.
WordPress - Enqueue by Page Tags
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
if ( $pageTags = get_the_terms( get_the_ID(), 'post_tag' ) ) { | |
$pageTagNames = wp_list_pluck( $pageTags, 'name' ); | |
if( in_array( 'slider', $pageTagNames ) ){ | |
wp_enqueue_script( 'pdms-slick', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js', array( 'jquery' ), '1.9.0', true ); | |
wp_enqueue_style( 'pdms-slick-styles', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css', '1.9.0', 'all' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment