I have more of a coding question. It maybe a question for stack overflow. I usually load custom scripts via a function (in functions.php)
I need to load a couple of custom scripts for only 2 specific pages to avoid it loading on all pages where it is irrelevant. I have for years done so with the function is_page
with an array pages I need it loaded on targeting with the page slug. Example below;
// GOOGLE MAPS INTEGRATION
function mossco_map_script() {
if(is_page( array('home', 'contact'))){
wp_register_script( 'google-custom-script', get_stylesheet_directory_uri() . '/assets/js/maps-ardee.js','','',true);
//LOAD SCRIPTS
wp_enqueue_script( 'google-custom-script' );
}
}
add_action( 'wp_enqueue_scripts', 'mossco_map_script' );
My question is with Wordpress FSE and the use of Templates instead of Pages what function would I use? is_page_template
? Iāve tried that but custom Templates how would I target them? No slug or ID that I can find. I also notice that the templates folder does not store any custom Templates. I have tried targeting /templates/home.html. Wordpress documentation, it says that is_page_template ()
compares against a ātemplate nameā, if one is provided.
I donāt know if any of the advanced users have attempted this.