You can either register the script and then enqueue it (which is how you’re doing it above), or you can simply enqueue it all in one go. Either way, if your script requires jQuery, you should designate it as a dependency with your registration, so WordPress will know to load it automatically for you.
So, either:
wp_register_script( 'menuscroll', get_template_directory_uri() . '/assets/js/menuscroll.js', array( 'jquery' ), false, true );
wp_enqueue_script( 'menuscroll' );
(Note that the ‘handle’ argument for the register and enqueue functions must match. The array tells WordPress you need jquery; false says, no special script version, and true says, load it at the bottom of the page.)
Or all in one go, like this:
wp_enqueue_script( 'menuscroll', get_template_directory_uri() . '/assets/js/menuscroll.js', array( 'jquery' ), false, true );
Ought to do the trick.
Related Posts:
- Add a class to links in the visual editor (how to get old dialog back)
- How to remove hardcoded characters from playlists?
- How to preserve PHP modifications while upgrading WordPress?
- Limit the Excerpt field in WP-Admin in words
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- How to add a do_action on refreshing of WP customizer?
- Menu jumping when calling it via PHP
- Media Upload , file name changed automatically
- Automatically refresh page if widget is added to page?
- custom field – changing an element or background of id div – different versions not working
- Cleaning up WordPress to improve performance?
- List of all theme customizer control types?
- Show the most popular post per week
- Creating custom Woocommerce attribute taxonomies from a plugin
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- Load post content into iframe
- wp_customize_image_control default value
- Calling a method from functions.php on a click of a button
- Get post meta in enqueued js file
- How to use WordPress (PHP) functions in AngularJS partials files?
- How to create a custom config file and get data using inline JS in a wordpress page
- Overriding a theme redux file in child theme
- Widgets not showing in my custom theme
- How to display custom field on homepage
- Archive dropdown styling not applied
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- Get/Set wp.customize.previewer.previewUrl
- How to make custom total price reactive in navigation
- Adding tawk.to code just before body tag on functions.php file
- How to get 2 or multiple custom post types in wordpress functions.php
- How can I output a php value into a JS file within WordPress?
- Creating bulk posts with Youtube videos
- How to test nonce with AJAX – Plugin development
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- Slider loading issue
- Creating a Multi-Level Associative Object Using AJAX
- remove wp floating submenu in wp dashboard
- search and replace preword from author
- How to complete two other input fields, completed the first
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Need Help Fixing My Iframes [closed]
- wp_enqueue_scripts leads to error
- Passing UTM Parameters To Modify Page In WordPress
- Open post-content in archive page in a Modal box with bootstrap
- Creating own shortcode – echoeing php variable based on JS variable
- Weird 404 URL Problem – domain name being placed at end of urls
- PhantomJS with wordpress
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Add / Update Custom Fields After Select Pictures in Media Window
- How to obtain the current website URL in my theme?
- Tell WP register script to load a script only when the entire page is loaded
- Hook called before text widget save
- How do I get an external php page to load using javascript
- Echo title attribute php
- str_replace with the_content is not working
- trying to put an active hover to my custom nav category buttons [closed]
- How do I get my Javascript scripts working?
- Calling PHP Titles inside Javascript Markup
- List of Events with Multiple Dates: Only NEXT Date
- ‘Bones’ theme: Load stock scripts in footer instead of header?
- Replacing WordPress Icons (menu,icons32, etc)?
- go to home page when i select default in select-box
- How to redirect non logged in mobile users to page on same site?
- Creating a brand attribute as a variable
- Decode and Decrypt Azure B2C OpenID Authorization Token, Use Response in API Call (Example Token Within)
- Integrate admin plugin into template. Very interesant (live search + autocomplete with wp rest api, in vanilla js)
- Hide A Class and Add Custom HTML Code Using WordPress
- Exclude ipads and tablets form wp_is_mobile code
- Dynamic “home” image and URL based on current folder
- gettint error 400 with AJAX
- Javascript / PHP – closing the loop
- I can’t load my images from a js file using wp_localize_script
- How to output values from a loop into a javascript array
- Redirect after login depending on the URL
- Bring Font Awesome icons inside menu A tags
- Autoloading Classes in Plugins
- custom post type column countdown
- Pass product object to javscript
- number of posts with “Load More”
- Call custom JS function from PHP
- How to send Ajax Call from frontend without using wp_localize_script in Theme
- Complex PHP for json_encode > how to handle/output right?
- Show content by using tags
- WordPress error on my website
- Best way to define a database with product codes and back-end support?
- Why this plugin is not working?
- wp_customize_image_control default value
- Trying to fix multiple category drop down
- Widget header unique classes
- How to add button to top of theme customizer?
- How can I add more code to this?
- Edit the Publish Widget Options
- Facebook share button only share the_permalink(), without thumbnail, tilte, excerpt, etc
- get_option(‘admin_email’) not working in wordpress when using ajax call
- how can I make content from a plugin hidden when user is logged in? [duplicate]
- New to WordPress & Freelancing [closed]
- Disable Typed Parameters for JavaScript in PhpStorm? [closed]
- Losing Session ID and sessionStorage when navigating to other domains on Multisite