I you want the script be enqueued on page-index.php and page-contact-us.php, then you must check that that page templates are used but you are checking if they are not used.
Chagne this:
if ( !is_page_template('page-templates/page-index.php') && !is_page_template('page-templates/page-contact-us.php') ) {
with:
if ( is_page_template('page-templates/page-index.php') || is_page_template('page-templates/page-contact-us.php') ) {
The first code reads like: if is NOT page-templates/page-index.php AND it is NOT page-templates/page-contact-us.php …
The second conditional reads like: if IS page-templates/page-index.php OR it IS page-templates/page-contact-us.php ….
You can use also an array of page templates to be checked:
if ( is_page_template( array( 'page-templates/page-index.php', 'page-templates/page-contact-us.php') ) ) {
Related Posts:
- How to load scripts/styles specific for a page
- Dequeue Scripts and Style for Mobile not working?
- Enqueue script o style only if a template part is loaded
- Enqueue scripts not working with if is page conditional tag in functions.php
- Only let plugin add actions to wp_head & wp_footer on single posts
- enqueue styles for only mobile wp
- Scripts not loading when using the wp_enqueue_scripts action
- Why does get_template_directory_uri() not include “www”, only for enqueued stylesheets?
- Theme JS is available but theme CSS isn’t
- Advanced method to control cache of enqueued style/script
- Add custom css file after plugin css with WordPress Child Theme functions.php
- wp enqueue style on about us page
- Test CDN link from function.php or wp_enqueue_script/style?
- How do I dequeue a Stylesheet, stored in an ‘Assets’ folder?
- I need to ‘wp_dequeue_script’ and ‘styles’ and ADD a bunch of other css and js
- Why is style.css not loading through the functions.php
- custom post with loading script per single post
- using enqueue_script in a shortcode isn’t working
- deregister scripts on certain page
- How to enqueue every script in a folder automatically?
- is_front_page not working in functions.php
- Most elegant way to enqueue scripts in function.php with foreach loop
- wp_register_script not loading as expected
- Problem using is_single() to enqueue script from functions.php
- I created a child theme and it doesn’t work for some of the css files
- Enqueuing External Javascript functions.php
- Child Theme Not Overriding Parent Theme
- How to enqueue JavaScript for specific WordPress pages only?
- Enqueue styles after a plugin
- How to override enqueued styles using a child theme
- Dequeue script in template isn’t working
- How do I get a child theme to load scripts from the parent theme?
- wp_enqueue_script add integrity parameter
- Passing arguments to my function with do_action and add_action is not working
- When using wp_enqueue_script(); in a theme why don’t we use add_action?
- Register and enqueue style.css custom theme
- wp_is_mobile dequeue not working
- Register vendor JS/CSS only on pages that require them?
- Why won’t my scripts load?
- Enqueue Style Only On Certain Pages Not Working
- functions.php How to add css/js depending on Template Name?
- Register and load scripts
- how to en-queue jQuery to load before the tag
- Attempt to change jQuery version caused White Screen of Death
- jQuery does not work
- enqueue_script with filemtime javascript not working
- different style sheet for just one page template
- add_action wp_enqueue_script priority level only works for admins
- linking stylesheets and scripts with functions.php
- Split Media Queries in different files!
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Enqueue script on every page except one
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- wp_enqueue_script | Help me figure out what is causing jQuery is not defined
- Load JS file only in specific template
- Parent theme styles overriding child theme CSS [closed]
- I can’t add CSS with functions.php
- Proper Way to Load stylesheet on Condition
- 404 when enqueue_script using plugin_url
- How to pass variables from one function to another or combine functions
- Do we need to change our child function.php to require/include child dir files when we add an over-riding file.php into the child theme
- video.js not enqueueing?
- Problem enqueuing scripts on not single posts
- Page Template Won’t Load Correct CSS File
- Call two different function.js depending on page
- Enqueueing a code block from an options framework
- Enqueueing scripts selectively & activation where needed
- Why is this function crashing my wordpress installation? [closed]
- colorbox not loading in
- Fatal error: allowed memory size when after using enqueue_script
- wp_enqueue_script() not working
- How to use wp_enqueue_script properly?
- How to load a css file depending on the current role
- localize_script but data changes dependent on product ID
- WordPress wp_dequeue_script remove all other scripts
- Is it possible to load recaptcha script only in url with fragment identifier (#)?
- How to reference different css (bootstrap) stylesheets for the header and body of a page?
- CSS style and app.js not loading
- Stylesheet does not load despite functions.php
- Why does my wp_enqueue_script() only insert the script for logged in users
- Unable to declare AOS library in functions
- Child Theme not loading multiple stylesheets
- I need to completely ‘wp_dequeue_script’; what’s the best way?
- WordPress Jquery+scripts enqueue issue
- Different body image backgrounds on different pages, posts and categories
- How to wp_enqueue_script with html?
- wp_enqueue_script only works outside of action
- Exclude javascript in certain page url and all following url’s after forward slash
- Print all inline styles to head
- java script error Uncaught SyntaxError: Unexpected token ILLEGAL
- Using array page name together with page id to deregister script
- Should I use `get_stylesheet_uri()` or `get_template_directory_uri()` when calling my CSS Stylesheet?
- Remove snippets of JS from core
- Why my wp_enqueue_script doesnt work on some page?
- How to fix enqueue_styles error for a twenty-seventeen childtheme
- wp_head not injecting css
- WordPress – Notice: Function wp_enqueue_script was called incorrectly
- dynamically import array from another js file in WordPress
- Auto updating JavaScript dependancy in functions.php
- wp_script_add_data not working