Don’t edit theme files. Your changes will be overwritten when your theme updates.
Instead use a child theme and hook into the wp_head function. Add this to your child theme’s functions.php file.
function add_js() {
?>
<script>
Your JavaScript goes here
</script>
<?php
}
add_action('wp_head', 'add_js');
BTW, as you have a commercial theme, you can also get support from your theme vendor.
Related Posts:
- Scripts at the end of the page
- Display a consistent Google Plus icon on ALL pages of my site
- Pass user role to javascript code inside body
- How to use custom Javascript code inside a plugin?
- What’s the default setting for including a in a post
- How to add specific script to WordPress webpage that will working with user input and databases
- Why can I not deregister my style and script on custom post type?
- Enabling plugin on specific pages and subpages
- How to include code only on specific pages?
- How can I create a bash install script for my WordPress sites setup (WP+plugins+theme)?
- How can I make content disappear when a user logs in?
- Why is the unrendered widget number `__i__` showing up in the JavaScript but not in the HTML?
- ‘Lazy loading’ list of posts with pagination
- How to Reload the Dashboard After Clicking Update in Quick-Edit?
- Styles and Scripts, Selectively enqueue across entire site
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- White text on white background in TinyMCE when wp_editor is called in WP 3.9
- What’s the best plugin for allowing javascript in a post or page? [closed]
- Is it possible to filter the wp_footer() scripts, read the content, and insert them inline?
- How can I make the “Preview Post” button save and preview in the same window?
- Disable / Deregister all JS from all plugins
- Has anyone used require.js for handling plugin scripts?
- Passing RichText attributes to function onChange
- Gutenberg List Extension Block
- javascript onload calling a function of a plugin
- JQuery not working in my plugin [closed]
- prettyPhoto media loading very slowly in Chrome
- How to load plugin after page is loaded – pagespeed issues
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- How to disable specific plugin in mobile version?
- Updating the Drag-To-Share eXtended share URLs?
- add image crop function like in wp customizer
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- How to edit content before post update
- wp.media javascript issue with on select
- WordPress + JavaScipt + AJAX + MySQL: insert query for form
- add input in custom javascript from WordPress pages/posts
- Advanced AJAX Page Loader ignores other JS code
- accessing wp.media api from a tinymce plugin
- How to load wp_editor via AJAX
- Redux Framework: Page freezes on typing in Editor
- WordPress 3.8.3. custom theme – sliders won’t load js/css files
- Redirect to another page using contact form 7? [closed]
- JavaScript in a PHP plugin
- How do I add some javascript validation to the admin interface form’s onsubmit?
- MediaElement.js works on one site but not the other?
- Can inactive WordPress plugins still load scripts?
- How to generate an all in one WordPress New content, plugin and theme update report on a website? [closed]
- How use wp media upload liberary in react components?
- JQuery needs to be defined in , but Gravity Forms is defining it in the
- Executing Javascript in Plugin
- WordPress Stats Plugin: Display Post Views [closed]
- Code for unique user visit count on every page WordPress
- Set Button in PluginDocumentSettingPanel Content (WordPress Gutenberg)
- WordPress load same script two times
- Upload Javascript and json webpage to wordpress
- Activate Plugin Automatically After Set Time
- Fixed: Console.log twice in the edit function
- Javascript embedded disappears for editors
- Trouble with AJAX using GET
- Preventing a missing or faulty plugin loaded inside of wp-settings from halting a script
- Get the link title attribute and send it google analytics as custom label via google tag manager using beehive pro for WordPress
- Calling PHP function with AJAX
- How can I add a custom Javascript snippet to display my feedback in footer?
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- WordPress site hamburger menu toggle not working
- How to add defer to WordPress Plugin javascript? [duplicate]
- How to get Angular app working in WordPress plugin?
- Custom Field used to allow a Free Story; no longer works
- Create a form and have custom menu display based on user answers?
- How to solve Blocked a frame with origin from accessing a cross origin frame error in wordpress?
- How to use information from the database in the front-end?
- how to send two forms with one click (script ninjaforms id)
- How to print shortcode with js in visual composer?
- Link in navigation menu send user to different page if mobile?
- How to change text in a page by utilizing a custom user id?
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- Creating a user ‘add custom field’ section
- Creating custom URL for async content
- Call/Run a Mathematica (.m) Shell Script from WordPress Page/Blog
- Plugin’s required JS not being inserted in my theme
- Need to hide an element depending on date and post category
- How do I convince this button to do something when it is clicked?
- contact 7 plugin stops some pages from working properly
- Can’t insert files in other inputs
- Is it possible to run javascript on plugin deactivated?
- How do I output user_registered time in my correct timezone?
- Ajax in Plugins: returns the whole page
- How to tweak a plugin without preventing it from updating
- WordPress shortcode plugin not working
- Defer parsing of JavaScript [duplicate]
- How do I put a word-press blog into my static site without installing wordpress on server?
- how to embed a crop feature for cropping images uploaded by the user
- How to access values from your own settings page in javascript?
- Refresh server side rendered block in Gutenberg without changing attributes or its content
- Scripts don’t enqueue after removing plugin
- How do I call an action hook into wp_ajax hook callback function
- I want to display data last 7 days with date wise in chartjs?
- this code is fiven by chat-gtp but nothing match even I key in the value of a cell. help!
- Use custom Javascript for a custom Elementor Widget [closed]