While you can approach it with “what template is loaded”, WP isn’t engineered for such logic. Template load is result of logic processing, not the other way around.
You should check out Conditional Tags and determine which logical check applies to your situation.
Other than that you should be:
- running script-related logic on appropriate
wp_enqueue_scripts
hook - let WP handle footer load (which you are doing via registartion), need for explicit print is extremely rare
Related Posts:
- Is there a way to set the order of wp_footer hooked functions?
- Including Javascript options
- jQuery not available to other scripts
- Single page site with history.js
- Enqueued JavaScript is not working
- How to register and enqueue JavaScript files without breaking plugin dependencies?
- Theme now uses require.js and enqueue script no longer works
- Does the functions.php file ever get called during an AJAX call? Debug AJAX
- theme path in javascript file
- Solutions for generating dynamic javascript / CSS
- Custom single template for a specific category
- How to insert a logo in the header?
- Proper, exhaustive documentation for wp.editor etc
- Page template in two level deep folder
- The difference between calling wp_enqueue_scripts to load scripts and styles in custom theme
- How does WordPress decide what template to use as frontpage
- Trigger Customizer saving process with Javascript only
- What can I hook into after_setup_theme?
- Problems with Layout inherit in theme.json
- How to Handle CSS for Multiple Header header.php Files?
- using wp_enqueue_script to attach jquery-ui
- Changing the entire control choices using wp.customize with JavaScript
- Static Front Page problem
- How to Change CSS Variable value in Theme Customizer Live Preview
- Can not Remove Archives and Meta from Sidebar
- Enqueued Stylesheets Effecting Admin Styles
- Dequeue script in template isn’t working
- wp_enqueue_script being ignored in custom theme
- Where is the correct place(s) in twentysixteen’s header.php to add a Google webfont?
- Whats the safest way to output custom JavaScript and Css code entered by the admin in the Theme Settings?
- WordPress Customizer Control with React
- Getting jquery to work with custom theme
- How to retrieve an image from a post and display it before excerpt of a post? [duplicate]
- How do I update WooCommerce template files in my theme? [closed]
- How to correctly add JQuery in a WP theme?
- Check if password protected post is visible
- What is the best way to handle multiple calls to get_template_directory_uri() and similar functions?
- Is there a filter for enqueue script to strip the type=”text/javascript” property
- Add theme templates for child categories into the template hierarchy
- Where can I access my custom page template?
- Theme development question regarding layouts
- Is my approach to enqueue styles inefficient?
- Disable front-page.php template
- How do I create a custom partial / template?
- Change the template of multiple multisite pages at the same time
- How to To Filter wp_enqueue_script() Scripts on Some Pages
- Load child template based on parent
- Where to call wp_enqueue_script in a plugin with custom template?
- JavaScript Change focus to password field login page being reset
- How to add Bootstrap Tour JavaScript to WordPress Admin Panel Dashboard Widget
- How to make Isotope and WordPress work together?
- how to display search term in the template full site editor
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- How to add material design css in wordpress and woocommerce
- Sort wp_query by sum of two meta fields
- How to: JQuery multiple wordpress media uploader buttons in the same options page?
- Move default page templates to sub directory
- How to get javascript slider to work! [closed]
- Searching multiple tags and adding jQuery dependant script onto page template?
- What can I use for small text when converting to WordPress?
- How to modify default controls in WordPress theme customizer
- My jQuery is enqueued properly. So why isn’t it working?
- Is there any tool to find lines of codes responsible to generate front-end HTML elements?
- How do I get the trackback count of a post in wordpress without writing an SQL query?
- Load sidebar template just once to prevent multiple animations
- Overide enqueue in non plugable function via child theme
- Broken theme, template is missing
- wp_enqueue_script not working?
- How to add menù section to my WordPress template?
- pass wordpress template directory into ajax url call
- theme-independent CSS/JS files
- Javascript development in Custom Themes
- How to add custom meta box when you have a custom page template file
- Password protect a custom template
- Custom jquery not code not working in wordpress
- Load different single.php templates according to post layout selection
- Confused by the behaviour of “front page” / “home” templates
- I need to develop a one-page design
- How to link to the page displayed by home.php?
- getBoundingClientRect() showing different values on load vs scroll
- wordpress script_loader_tag in function.php
- How to diagnose wp-env environment problem
- how can i remove js file from my footer in wordpress
- Find out the reason that the Styles and scripts in the theme are loading properly in localhost but Not in server after deploying
- Different templates for each category level
- Customizer Image-Picker Preview Not Working
- Child theme in separate WordPress Install
- how can I re-utilize and class on a child theme
- How to show children pages as array
- Theme customizer live preview JS- Trying to bind to an html image url without luck
- enqueue script if page is not equal to
- wp_deregister_script was called incorrectly
- Using wp_enqueue_script with social media buttons?
- wp_enqueue_script causes page to vanish
- How to reuse parts of WordPress site e.g. header, footer, part of header for multiple WordPress sites?
- Best practice to create required pages
- WP site makes mobile browser crash for high memory usage
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?
- What is the point of using archive.php instead of index.php?
- When trying to run build script with gutenberg (with SVG import) – Error: Plugin name should be specified