You should be able to just dequeue the script or style if it’s not the pages you want it on.
function wpa_scripts() {
// if this is not the contact page, remove the script
if( ! is_page( 'contact-us' ) ){
wp_dequeue_script( 'contact-form-7' );
}
}
// adjust priority to make sure this runs after the plugins add their scripts/styles
add_action( 'wp_enqueue_scripts', 'wpa_scripts', 100 );
Related Posts:
- Pass $this to function nested in another public function of the same class
- Dequeue / Deregister script and replace it with a new plugin
- Is it possible to add an action to the currently running action?
- Where does WordPress register default scripts like jQuery?
- plugins_url function mixes system path and URL
- Plugin and theme script load order
- React JSX in WordPress Plugin Development
- Use wp_enqueue_scripts from included php file
- Adding Font Awesome to WP Plugin
- Register google jquery gets overwritten by plugin
- Dequeue, Unregister, Remove Action – Not Working on Plugin
- Enqueue script: link not working in page source
- plugins_url not returning correct directory
- How do I keep children of certain parent menus expanded by default on a sidebar?
- Enqueue scripts in the footer
- Trying to use wp_register_script/style and enqueu them from an array – getting an error [duplicate]
- How to maintain W3C standards compliance of a theme
- Load plugin on specific page only
- Does a plugin’s “main” file need to be named the same as the folder containing it?
- What causes the “Are you sure you want to do this?” error with plugins?
- enqueue script only if it is not already enqueue
- Display (and manage) webcam images?
- Overwrite textdomain of plugins by default – Lost Translation
- jQuery plugin only in one page/post
- Google Analytics post views in WordPress? [closed]
- scheduled event not getting executed
- How can I limit functionality in one version of a plugin?
- Any way to use a custom Parameter for youtube embed without using an iframe?
- Hook (upgrader_process_complete) running moment
- Is it possible to upload a template file to a directory that can be used by all themes?
- WordPress hook for visiting a post
- why does the add_action(‘the_content’) overwrite my page
- Error Message from W3 Total Cache when .htaccess Rules Cannot Be Modified? [closed]
- Is it ok to call get_option without hooks?
- Send emails with wp_mail() using SMTP configured in plugin
- Show “Local Pickup” shipping method only for specific Woocommerce product categories [closed]
- How can I measure the performance of any WordPress Plugin or Theme?
- Can I check plugins and themes for PHP 5.6 ahead of global PHP server Update
- How can I reuse the WordPress search form for a custom plugin / widget?
- Can you switch the type of WordPress site you have?
- Where should a plugin or widget cache its results?
- Set of plugins to control the Admin UI
- How to get all plugins and their version numbers from the local files?
- Do We Need to Validate, Sanitize, or Filter Simple Numerical Superglobals (Cookies and Post)?
- How to transfer all user data between wordpress installations?
- Plugin upgrade issue
- Integrate BuddyPress & Facebook
- __callStatic method handler passed to add_action causes bug in PHP
- Multiple instances of nivo slider plugin
- New databes tables with – WooCommerce – for developers [closed]
- Interactive filters on wordpress [closed]
- Add padding while generating thumbnail
- ACF only showing up in Homepage but doesn’t appears in all pages
- One file for all translations
- Send admin an email when a user’s search has no results
- How to Loop Through all Posts and Count Attachments using Get Media Attachments
- Shortcode not working after move wordpress website files
- Contact Form 7 – Form name blank [closed]
- plugin dev – minimum base css specificity?
- Help with comments.php
- OceanWP settings are missing from Add New Post [closed]
- How to place a function from another class in add_action 2nde argument?
- Loop returns the current page’s permalink and guid instead of the post in the loop
- display connected User to post
- Creating an admin meta box to save post as pending
- Plugin upgrade failing during unzip
- How i can remove Working Functionality of my header & footer plugin from backend files but in front end plugin need to show that plugin activate
- WoCommerce Cart is not showing pricing
- Plugin or ways to limit number of users logging in the website,
- WP Ajax DB issues
- How to capture hidden values with Gravity Forms
- Hide response returned from WordPress REST API call
- Paid Membership Pro displaying a user name in PHP
- Customize plugin’s output: filters or setters: looking for an advice
- Uncaught TypeError: Cannot read property ‘cycle’ of undefined
- Make another copy of a plugin and install it
- WordPress drop domain alias
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- WP Plugin CSS not being applied to page
- In the WordPress API is there a way to set the width of the post/page container
- Unable to sync woocommerce variations
- Plugin does not create a custom table upon activation
- Automatic updates of plugins and themes outside of wordpress.org
- Plugin hook breaks new WP 4.0 media library grid view?
- How to get site homepage from plugin?
- Contact Form loaded with Ajax
- Link Forms on WordPress
- How to correct Error: message on website Twitter Feed
- homepage olderposts link showing page not found
- Image rotator plugin
- Vote It Up Plugin – Add ascending numbers to MostVotedAllTime Chart Function
- Automatically set posts to NoIndex depending on category?
- Custom time field won’t sort regardless of format
- Move specific javascript to the footer
- How to send email when my plugin is activated?
- Why does theme need woocommerce to show images / content on front page?
- wordpress Ajax success doesn’t return the value
- How to get URL param for pagination in shortcode?
- How to add an active state class to my info box
- Using ACF to allow user to add and edit multiple saved forms