So I've got a script that I'd like to include in only a template file. The template file is located in a folder called templates in my child theme. I thought I could do it by including an if statement in functions.php and targeting the template file by name like so:
function header_anim() {
wp_enqueue_script( 'head', get_stylesheet_directory_uri() . '/js/head.js' );
}
if( is_page_template( '/templates/home-template.php' )) {
add_action( 'wp_enqueue_scripts', 'header_anim' );
}
However, it seems as though it's not recognizing the if statement for some reason.