Add enqueue_script code into functions.php

This commit is contained in:
Markus Ankenbrand 2017-02-20 23:28:56 +01:00
parent c0e24a4206
commit c615a59e19
2 changed files with 9 additions and 3 deletions

View file

@ -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();
}
}
}
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');

View file

@ -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));
?>