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_scriptshook - 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
- Solutions for generating dynamic javascript / CSS
- Custom single template for a specific category
- 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
- How can I get wp_head() as a string instead of echoing it?
- Why does my short code get executed before other content?
- What does “Do not deregister the jquery script in the administration area” mean?
- How can I see what template parts are being called for rendering the viewable page?
- 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
- Can not Remove Archives and Meta from Sidebar
- Modifying JS files in Child-theme
- Setting hero/splash section as a blog post
- 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?
- 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 to configure wordpress to work with Vuejs with SSR and without hashbang
- get_query_var() and permalinks
- Toggle Sidebar Display
- Add theme templates for child categories into the template hierarchy
- Move theme templates to subfolder without losing page associations
- Where can I access my custom page template?
- Why are theme templates organized as multiple point of entry PHP files instead of reusing your theme’s index.php?
- How do I create a custom partial / template?
- functions.php not hooking up with style.css
- way to include own functions independent of theme
- How to To Filter wp_enqueue_script() Scripts on Some Pages
- Load child template based on parent
- Single Page theme [closed]
- How to make Isotope and WordPress work together?
- how to display search term in the template full site editor
- How to add material design css in wordpress and woocommerce
- Sort wp_query by sum of two meta fields
- Can´t access child theme´s scripts dependencies found in parent
- Theme Javascript.php Overwritten Nightly [closed]
- How to override p2 breathe theme plugin in content template file?
- Searching multiple tags and adding jQuery dependant script onto page template?
- What can I use for small text when converting to WordPress?
- Where to place template files?
- 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
- Replace single_template filter with what for default posts?
- Need help with adding templates (archives and sitemap) to WordPress child theme
- How to seperate static phrases from template files in custom theme?
- 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?
- Run a jquery script on on a certain template page
- Post and page content not displaying in search results
- Why still output /wp-content/themes/twentynineteen?
- 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
- Templates dropdown not appearing using _s theme (underscores)
- Load different single.php templates according to post layout selection
- I need to develop a one-page design
- How to link to the page displayed by home.php?
- Under theme folder, what’s sequence of action for index.php, page.php, single.php?
- Is there a template tag I can use to link to the archive page corresponding to the month that a post was published on?
- Adding google fonts to WordPress theme
- 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
- Template for front page (latest posts)
- which template should I use for single category post?
- Different templates for each category level
- Child theme in separate WordPress Install
- How to show children pages as array
- Using require_once for parent-directory not working but is working in sub-directories
- 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?
- Enqueue script/style with multiple GET parameters
- What is The Best Way to Make Parallax header effect for wordpress theme ?? pure CSS or using JavaScript? [closed]
- Best practice to create required pages
- WP site makes mobile browser crash for high memory usage
- 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
- Smooth Scrolling Animation of Image Between Two Containers (Elementor) Using JavaScript and GSAP
- How to create a template for a post in Query Loop block?
- Javascript localization doesn’t load. How to Internationalize javascript without plugin?
- Twenty Twenty-Four Theme, where to put the personalized CSS style rules?