From c615a59e197b2d6ffd02a6d5aca7e2fd4a1f24b2 Mon Sep 17 00:00:00 2001 From: Markus Ankenbrand Date: Mon, 20 Feb 2017 23:28:56 +0100 Subject: [PATCH] Add enqueue_script code into functions.php --- functions.php | 11 +++++++++-- page-pins.php | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/functions.php b/functions.php index b8c2ee8..5816fd5 100644 --- a/functions.php +++ b/functions.php @@ -6,7 +6,7 @@ function td_theme_styles() { wp_enqueue_script( 'google-maps', '//maps.googleapis.com/maps/api/js?key=AIzaSyDHNT102YHu-TP50F78bPyvf5ia6K6cjU8&callback=initMap', - array(), + array('page_pins_map'), '1.0', true ); @@ -82,4 +82,11 @@ function atravelblog_related_posts() { add_post_image_thumbs($urlaub, 'Urlaub:'); wp_reset_query(); } -} \ No newline at end of file +} + +function enqueue_page_pins() { + // change the template file name according to your file + if ( ! is_page_template('page-pins.php') ) return; + wp_enqueue_script('page_pins_map', get_stylesheet_directory_uri() . '/js/page-pins-map.js', array('jquery'), null, true); +} +add_action('wp_enqueue_scripts','enqueue_page_pins'); \ No newline at end of file diff --git a/page-pins.php b/page-pins.php index 9a63645..2965821 100644 --- a/page-pins.php +++ b/page-pins.php @@ -78,7 +78,6 @@ } } endwhile; - wp_enqueue_script('page_pins_map', get_stylesheet_directory_uri() . '/js/page-pins-map.js', array('jquery')); wp_localize_script('page_pins_map', 'page_pins_map', array('places' => $locations, 'traveler' => $traveler)); ?>