is_page_template & is_page in functions.php not working

Use wp_enqueue_scripts instead on init. This will ensure you the template is already loaded.

add_action('wp_enqueue_scripts', 'maps_scripts');

Or you try to check the template using get_page_template_slug() instead of is_page_template:

$tmp = get_page_template_slug($post_id); // provide page/post ID
if('page-about.php' == $tmp) {
    // enqueue scripts here
}

Note that you don’t need to register scripts before enqueueing them. Simply pass all the parameters of wp_register_script directly to the wp_enqueue_script (see the Code Reference).

Leave a Comment