add_action( 'wp_enqueue_scripts', 'ron_scripts' );
function ron_scripts(){
if(is_home()){
wp_register_script( 'homescript', '/wp-content/themes/template/js/menu-home-open.js' );
wp_enqueue_script( 'homescript' );
} else {
wp_register_script( 'nothomescript', '/wp-content/themes/template/js/FILENAMEHERE.js' );
wp_enqueue_script( 'nothomescript' );
}
}
alternatively replace is_home();
with any other method or code that determines what page you are on. ex:
might work
if(site_url() == get_permalink()){
//do home stuff
} else {
//do not home stuff
}
Related Posts:
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- wp_enqueue_script being ignored in custom theme
- Getting jquery to work with custom theme
- Adding wp_enqueue_media(); causes problem
- Toggle Sidebar Display
- Including Javascript options
- Unhook jQuery from WooCommerce via `functions.php`? [closed]
- Difficulty loading jQuery with wp_enqueue_script
- jQuery not available to other scripts
- Custom theme, contact form 7 & fast secure form doesn’t work
- JQuery undefined and Stylesheet loads in bottom along with js files
- how can i remove js file from my footer in wordpress
- Theme now uses require.js and enqueue script no longer works
- Get the blog page URL set in Options
- Change admin bar to default:off
- Create “File-less” Page Template in Functions.php
- When to use esc_url, esc_html, esc_attr, and friends?
- How to edit bbPress template files – WordPress + BuddyPress + bbPress? [closed]
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- What can I hook into after_setup_theme?
- What is the best practice for customizing a plugin’s JavaScript/jQuery?
- Override default cropping in WordPress [duplicate]
- Removing the default sidebar from admin panel
- How to Change CSS Variable value in Theme Customizer Live Preview
- How can I loop into two different DIVS without repeating the DIVs
- Enqueued Stylesheets Effecting Admin Styles
- Change date number to another language/script?
- Nesting Functions within Functions
- Is using eval() ok in this scenario
- Enqueuing Script in functions.php vs on the page
- Dequeue script in template isn’t working
- Custom php page in WordPress theme?
- Can’t access WordPress functions in file called via Ajax?
- How to correctly add JQuery in a WP theme?
- how do you create an admin interface in plugin for your theme
- How to determine which custom header image is being shown
- Is there a filter for enqueue script to strip the type=”text/javascript” property
- trying to use wp_handle_upload with ajax
- Is my approach to enqueue styles inefficient?
- WP 3.1 upgrade breaks AutoFocus+ theme
- How to add Bootstrap Tour JavaScript to WordPress Admin Panel Dashboard Widget
- My javascript jquery won’t work?
- Not sure if enqueuing js scripts properly
- after renaming my wp-content folder, how do I upgrade my wordpress version?
- Implementing FancyBox
- Pass variable to hook. Its possible?
- enqueue styles for only mobile wp
- How to: JQuery multiple wordpress media uploader buttons in the same options page?
- how to en-queue jQuery to load before the tag
- How to modify default controls in WordPress theme customizer
- How to disable controls in theme customizer?
- Theme Customizer not loading JS for live preview
- Post thumbnail to append post content via ajax click event
- Remove “You are using WordPress 3.2.1” from Right Now Dashboard Widget
- Replace function in a child theme
- jQuery does not work
- My jQuery is enqueued properly. So why isn’t it working?
- Enqueued JavaScript is not working
- Replace single_template filter with what for default posts?
- Overide enqueue in non plugable function via child theme
- How to register and enqueue JavaScript files without breaking plugin dependencies?
- In jquery use php variable to execute an enqueued jquery file
- Theme not calling Jquery properly
- Weirdness in jQuery supplied with WordPress
- Run a jquery script on on a certain template page
- How to fix : Uncaught ArgumentCountError: Too few arguments to function? [closed]
- How to enqueue a script which is type module without using script_loader_tag filter?
- jQuery from parent theme loaded with many other scripts in a single min.js file
- Custom jquery not code not working in wordpress
- How to load jQuery in TOP of wp_footer?
- Include Jquery libraries in wordpress theme?
- Trouble in enquing all js files under certain directory
- add jquery file if a certain page is included
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Add content after get_header
- Can’t change theme name
- How to set default values for edit_post_link() in my theme?
- How do I implement jPanelMenu?
- I don’t think WordPress is loading jquery or bootstrap js
- Adding google fonts to WordPress theme
- Advanced method to control cache of enqueued style/script
- Test CDN link from function.php or wp_enqueue_script/style?
- How to load jQuery with Ajax in WP version 5.3.2?
- How to enqueue scripts properly with ES6 webpack?
- Infinite scroll without plugin using ajax
- True parameter but jquery register in header and not in the footer with wp_register_script
- how to add jquery to wordpress
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- How would I get this to work – send to post from thick box
- WordPress custom jquery not found
- Passing a location-dependent array via wp_localize_script within a shortcode
- Set start page depending on screen width [closed]
- loading custom.js file after jquery is loaded
- Enqueue script/style with multiple GET parameters
- themeforce (happytables framework) implementation
- WP Customizer get control value on change
- Execute javscript when theme customizer loads (autosave issue)
- WordPress Includes mejs 404 error