Via functions.php, I'm trying to enqueue specific scripts and styles based on two separate page templates. Here's what I've tried:
if ( !is_page_template('page-templates/page-index.php') && !is_page_template('page-templates/page-contact-us.php') ) {
// Map
wp_enqueue_script('google-map', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false');
wp_enqueue_script( 'map', get_template_directory_uri() . '/js/map.js', array('jquery'), '20160408', true );
// Map markers
wp_enqueue_style( 'markers-style', get_template_directory_uri() . '/js/map_markers/css/map-icons.min.css', array(), '20160409', 'all' );
wp_enqueue_script( 'markers', get_template_directory_uri() . '/js/map_markers/js/map-icons.min.js', array('jquery'), '20160408', true );
}
I'm expecting the scripts to enqueue on page-index.php and page-contact-us.php when I visit the pages assigned to those page templates. They are not enqueuing at all with the current code. What am I doing wrong here?
wp_enqueue_scripts
. also noteis_page_template
cannot be used inside the loop. – majick Apr 12 '16 at 16:11function theme_scripts() {
via functions.php using the _s theme. – Sam Apr 12 '16 at 16:15