Move your project_dequeue_unnecessary_scripts()
function to your functions.php
file and add a conditional statement to determine if the appropriate template is being loaded. E.g.:
// Remove Mobile Header
function project_dequeue_unnecessary_scripts() {
if ( is_page_template( 'name-of-template.php' ) ) {
wp_dequeue_script( 'enterprise-responsive-menu' );
wp_deregister_script( 'enterprise-responsive-menu' );
}
}
add_action( 'wp_print_scripts', 'project_dequeue_unnecessary_scripts' );
I suspect that your function is not working because it has been placed somewhere after the call to get_header()
in the template file which means it would be too late to dequeue the script. Declaring functions in template files is not a good practice anyway, so use your functions.php
file or another include.
Related Posts:
- Dequeue Scripts and Style for Mobile not working?
- When using wp_enqueue_script(); in a theme why don’t we use add_action?
- How to enable template page only for a post id page
- enqueue styles for only mobile wp
- Define PHP variable from a seperate API if statement
- Run a jquery script on on a certain template page
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Advanced method to control cache of enqueued style/script
- WordPress wp_dequeue_script remove all other scripts
- Test CDN link from function.php or wp_enqueue_script/style?
- WP Enqueue Script Error
- Issues with title-tag and document_title_parts
- How to load scripts/styles specific for a page
- WordPress Enqueue for homepage only, functions.php, wp-framework
- Is it ok to use a function to output the text domain name in a wordpress theme
- Display random categories on the front page (Finding and Editing Theme Functions)
- How to redirect to post if search results only returns one post
- How to get woocommerce inventory status [closed]
- How to override admin-bar style
- TinyMCE custom styles remove class when switching styles
- deregister scripts on certain page
- How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
- Enqueue Script with data attributes
- wp_get_attachment_image returns different image size
- How to enqueue every script in a folder automatically?
- Passing variables to templates (alternatives to globalizing variables)
- Load post with a different template?
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- Organize functions.php
- How to customize search result page title?
- How to override functions.php in child theme?
- Overriding core functions in child theme
- How to fix a theme with page.php Default Template that accidentally deleted?
- WordPress Change Post Templates,but not drop down, but Image selection
- Most elegant way to enqueue scripts in function.php with foreach loop
- Change parent theme file function in child themes functions.php
- wp_register_script not loading as expected
- Problem using is_single() to enqueue script from functions.php
- Add inline css to theme
- Returning Variables back into a template
- Using locate-template & shortcodes doesn’t appear to work
- Enqueuing External Javascript functions.php
- How to enqueue JavaScript for specific WordPress pages only?
- Can I use require() function in a template file?
- Displaying Widgets
- How to set global variables in template page?
- Enqueue script o style only if a template part is loaded
- Why isn’t is_page_template() adding a body class?
- Enqueuing Script in functions.php vs on the page
- Query children and parent title
- Help to resolve Syntax error, unexpected ‘endwhile’ (T_ENDWHILE) [closed]
- Adjust which tempalte a page uses with a function?
- How to change menu icon which is overriden (i.e. by WooCommerce) [closed]
- Add external js file to footer with id
- Changing itemprop from logo to image on custom logo?
- How to add background image control to page admin controls?
- Make “sidebar template” the default template for new pages
- Best Practice for Syncing Local Development With Staging Development [closed]
- Overwrite Parent Theme add_image_size in Child Theme
- Retrieve post modified date for specific post by post ID
- Show excerpt for only first post in query
- How to add css class to image attached in all the posts?
- If is multiple page templates
- Toggle Sidebar Display
- How do I get a child theme to load scripts from the parent theme?
- wp_enqueue_script add integrity parameter
- How to call custom function from functions.php in site-wide template files?
- How to use thumbnails in gallery?
- Logic to Print/echo a css class only for 1st post and ignore all post after 1st? [closed]
- Attach parent category template to all subcategories
- Passing arguments to my function with do_action and add_action is not working
- Add class or ID to any WordPress function
- Is there a way to add a class to non current menu item?
- Load JS Script only for custom post types
- How to remove howdy dropdown menu content
- How to include local menu based on page id?
- How to create function from code?
- How to use Internationalized human_time_diff() function in Chinese?
- Display Password Protected external RSS in wordpress template
- is_dynamic_sidebar always returns true while using Jetpack visibility
- How to extract the variables out from “add_shortcode” function?
- Default Gallery Edit/Template Editable?
- Enqueue scripts not working with if is page conditional tag in functions.php
- wp_is_mobile dequeue not working
- Register vendor JS/CSS only on pages that require them?
- Why won’t my scripts load?
- Selective Product Category for Carousel
- How to change login labels
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- Modify a function without editing template
- Retrieve tags data in post body
- Add caption functionality to custom WordPress theme
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- Override a theme function in a child theme?
- Pulling Twitter RSS feed not working as expected (fatal error)
- Not sure if enqueuing js scripts properly
- Only let plugin add actions to wp_head & wp_footer on single posts
- Register and load scripts
- Use register_setting() in a loop