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
- How to Use Webpack with WordPress Script Modules and Enqueue a Custom Class
- 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?
- 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
- How to enqueue javascript for WP Customize options sidebar?
- Theme Customizer not loading JS for live preview
- 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
- Template for landing pages
- Unique design inside a specific category’s url
- 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
- How can I wrap all blog posts image with
- How to fix : Uncaught ArgumentCountError: Too few arguments to function? [closed]
- Why still output /wp-content/themes/twentynineteen?
- White screen when attaching css to function.php
- WordPress theme resource won’t load over VPN
- How to enqueue a script which is type module without using script_loader_tag filter?
- 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)
- Shortcode call not working in WP Template
- Load different single.php templates according to post layout selection
- Create theme for mobile phones and tablets only?
- Confused by the behaviour of “front page” / “home” templates
- I need to develop a one-page design
- How to create a WP theme that use BootStrap? [closed]
- 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?
- enqueuing external and internal js and css in wordpress did not work with owl.js animate.css
- Adding google fonts to WordPress theme
- getBoundingClientRect() showing different values on load vs scroll
- wordpress script_loader_tag in function.php
- How to Modify WP_Includes/blocks/latest_posts.php
- How to diagnose wp-env environment problem
- how can i remove js file from my footer in wordpress
- How to implement pagination in category.php template
- Find out the reason that the Styles and scripts in the theme are loading properly in localhost but Not in server after deploying
- How to enqueue scripts properly with ES6 webpack?
- Ajax Comment Upvotes – Votes don’t always register
- change background image on scroll
- Enqueue script for development purposes only?
- Template for front page (latest posts)
- Using wp_add_inline_style Inside a Template File
- which template should I use for single category post?
- Should I use template files or just use conditional tags in index.php?
- Different templates for each category level
- Customizer Image-Picker Preview Not Working
- Correct was to customise theme using get_theme_mod in scripts
- Does any JavaScript file load automatically for index.php file?
- Child theme in separate WordPress Install
- how can I re-utilize and class on a child theme
- How to show children pages as array
- Display content on Single page
- Create a variable with string, array or multiple values
- Using require_once for parent-directory not working but is working in sub-directories
- How would I get this to work – send to post from thick box
- How can I fix the even/odd child classes comments so that the comments are unaffected by the top-level even/odd?
- How do I get my theme scripts to load in a custom theme built from Bootstrap
- Flexslider not working for my custom theme WordPress
- Problem with multiple menus in theme
- Theme customizer live preview JS- Trying to bind to an html image url without luck
- Enable WP to accept standard jQuery code embeding between the tags [duplicate]
- Can’t attach Javascript to theme
- enqueue script if page is not equal to
- Set start page depending on screen width [closed]
- wp_deregister_script was called incorrectly
- Paginated WP_Query doesn’t return 404’s, even when posts don’t exist
- Using wp_enqueue_script with social media buttons?
- How to convert that page to a wordpress template? [closed]
- wp_enqueue_script causes page to vanish