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
- Display notification only once
- Add attribute / custom attribute to product in woocommerce
- Access/update database with jQuery
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- Get/Set wp.customize.previewer.previewUrl
- javaScript in section of WP API
- Why WordPress architecture is not pure object oriented and it don’t use MVC pattern? [closed]
- How to break down importing of feeds
- admin-ajax.php responding with 0
- Using wp_localize_script to store the template url into a variable to use in JS
- How can the plugin directory path be returned into ?
- Wrap First Character after in a tag
- How can I add tinymce editor in WordPress with jQuery?
- How to speed up admin-ajax.php in wordpress
- JQuery not working on WordPress Admin page [closed]
- Customizer Show/Hide
- Page Reloads Before AJAX Request Finishes
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- How do I implement a .diff changeset from core.trac.wordpress.org locally?
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- How to make custom total price reactive in navigation
- PHP can I add line numbers to file_get_contents()
- Adding tawk.to code just before body tag on functions.php file
- How do I fetch all comments per post via WP REST API?
- How to get 2 or multiple custom post types in wordpress functions.php
- Deregistering a script in WordPress seems impossible
- Slide in Panel WordPress Post
- Sending jsPDF documents to the server
- How to prevent those PHP variables from being cached on WordPress?
- Ajax return code 400
- Multiple choice in a custom taxonomy
- How can I add an alert (like the old javascript alerts) to my WP page?
- Pass PHP variable to JavaScript without inline JS
- Displaying theme options in css
- Show post in slider
- How can I output a php value into a JS file within WordPress?
- Creating bulk posts with Youtube videos
- Using shipped version of jquery
- Putting PHP variables into javascript [duplicate]
- Random Default Avatar Function
- Bridging TinyMCE js and WordPress PHP?
- Trying to implement Ajax comments in WordPress, getting WP error
- How to test nonce with AJAX – Plugin development
- How do I display a user’s previous orders as a select box option on a product?
- Simple Plugin with custom javascript wont work – no console error
- Hide wordpress field if data is empty in post!
- How does this WordPress Plugin (Thrive Comments) apply their custom comment sort? [closed]
- How can I use a modal window to display the current post in loops featured image?
- js file in root loading without
- Change the site tagline (or similar) based on current page
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- class click counter save number
- Setting custom canonical urls
- Trigger popup in a php if/else statement
- Only show search results with if current date is between two dates?
- database interactions using OOP
- Customizer: Output default value in Customizer CSS
- How to add just one specific page to widget without plugin?
- Remove one value in dismissed_wp_pointers?
- Slider loading issue
- create a select input with menus created on a custom options page
- Taxonomy linked to pages
- AJAX request status 200 but no actual “response”
- Button not refreshing page
- Ajax not working es expected (Returns 0)
- Use menu link or onClick to set a variable
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- How to select the contents in the text view textrea in wp_editor?
- Creating a Multi-Level Associative Object Using AJAX
- Accessing data from a non-WP database/table within a page content
- WP functions in .js
- Adding custom directory and PHP files in wordpress
- WordPress blog post url on category page
- Changing layout with wp_customise
- WP dynamic featured image – Can’t get second featured image url
- Converting HTML Template to WordPress Theme
- Extending the WP_Widget_Text class
- Ajax – Call to undefined function get_option()
- Selectbox in admin panel function linking to CSS
- Can I install/embed WordPress on a ‘single page’?
- Populate dropdown with Child Pages based on Parent Page chosen
- remove wp floating submenu in wp dashboard
- Displaying admin notices inside the block editor from rest_after_insert_{$this->post_type} hook
- search and replace preword from author
- How to prevent XSS alter custom global javascript object & methods in WordPress
- How to check if a meta value has already been assigned to any user?
- How to hide products that do not have an image from a slider carousel for an ecommerce webpage?
- How to complete two other input fields, completed the first
- Status 400 for AJAX POST Request with admin-ajax.php