Use wp_localize_script to pass data from php to your javascript:
wp_register_script(
'wpa_script',
get_template_directory_uri() . '/js/script.js',
array('jquery'),
null,
false
);
wp_localize_script(
'wpa_script',
'WPAData',
array(
'slides' => array( 'http://google.com', 'http://google.co.uk' )
)
);
Related Posts:
- jQuery not available to other scripts
- Theme now uses require.js and enqueue script no longer works
- How to include jQuery and JavaScript files correctly?
- pass object/JSON to wp_localize_script
- jQuery in header or footer
- Is there a way to set the order of wp_footer hooked functions?
- What is the best practice for customizing a plugin’s JavaScript/jQuery?
- How to Change CSS Variable value in Theme Customizer Live Preview
- wp_enqueue_script being ignored in custom theme
- Getting jquery to work with custom theme
- Adding wp_enqueue_media(); causes problem
- How to correctly add JQuery in a WP theme?
- Difficulty loading jQuery with wp_enqueue_script
- How to: JQuery multiple wordpress media uploader buttons in the same options page?
- My jQuery is enqueued properly. So why isn’t it working?
- Enqueued JavaScript is not working
- How to register and enqueue JavaScript files without breaking plugin dependencies?
- add jquery file if a certain page is included
- how can i remove js file from my footer in wordpress
- How to enqueue scripts properly with ES6 webpack?
- change background image on scroll
- How would I get this to work – send to post from thick box
- enqueue script if page is not equal to
- Set start page depending on screen width [closed]
- can’t add EVENT LISTENER to a element
- jQuery Snippet Not Working on WordPress Site [closed]
- WP Customizer get control value on change
- Execute javscript when theme customizer loads (autosave issue)
- Does the functions.php file ever get called during an AJAX call? Debug AJAX
- theme path in javascript file
- Solutions for generating dynamic javascript / CSS
- force enqueue script to be first in order of prominence
- Proper, exhaustive documentation for wp.editor etc
- Move WordPress native javascript to bottom of page?
- The difference between calling wp_enqueue_scripts to load scripts and styles in custom theme
- Trigger Customizer saving process with Javascript only
- What can I hook into after_setup_theme?
- How to Add a .js file Only in one specific Page Dynamically to Head
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- using wp_enqueue_script to attach jquery-ui
- Use js script from one plugin in another plugin
- Changing the entire control choices using wp.customize with JavaScript
- How wp_enqueue_script works?
- Enqueued Stylesheets Effecting Admin Styles
- Whats the safest way to output custom JavaScript and Css code entered by the admin in the Theme Settings?
- WordPress Customizer Control with React
- Script won’t execute in the media manager
- How to properly add Bootstrap and JQuery Javascripts?
- Is there a filter for enqueue script to strip the type=”text/javascript” property
- Fancy-box Esay wordpress plugin fails to work on Multilingual site
- Enqueuing javascript files
- functions.php not hooking up with style.css
- way to include own functions independent of theme
- How to To Filter wp_enqueue_script() Scripts on Some Pages
- JavaScript Change focus to password field login page being reset
- How to add Bootstrap Tour JavaScript to WordPress Admin Panel Dashboard Widget
- How to make Isotope and WordPress work together?
- How to add material design css in wordpress and woocommerce
- Can´t access child theme´s scripts dependencies found in parent
- Theme Javascript.php Overwritten Nightly [closed]
- How to get javascript slider to work! [closed]
- Searching multiple tags and adding jQuery dependant script onto page template?
- Post thumbnail to append post content via ajax click event
- Would to use AJAX to get an option from the database and use it in a jquery setup or is there an alternative to consider?
- Custom theme, contact form 7 & fast secure form doesn’t work
- WP Plugin Running before jQuery
- Javascipt issue on custom theme
- Overide enqueue in non plugable function via child theme
- wp_enqueue_script not working?
- Loading scripts on a single page plants the script in the footer
- pass wordpress template directory into ajax url call
- theme-independent CSS/JS files
- Using function from enqueued .js file in theme in plugin?
- jQuery from parent theme loaded with many other scripts in a single min.js file
- Javascript development in Custom Themes
- Custom jquery not code not working in wordpress
- Using WP functions inside javascript
- How do I implement jPanelMenu?
- Adding google fonts to WordPress theme
- getBoundingClientRect() showing different values on load vs scroll
- How to diagnose wp-env environment problem
- How to properly use AWS SES for a contact form?
- Find out the reason that the Styles and scripts in the theme are loading properly in localhost but Not in server after deploying
- Add a Script button in W3 Total Cache plugin not working due to conflicting jQuery version
- JavaScript code do not works on online server
- how to add jquery to wordpress
- Enqueue javascript that inserts custom php widget into jQuery-constructed div
- Theme customizer live preview JS- Trying to bind to an html image url without luck
- wp_deregister_script was called incorrectly
- Using wp_enqueue_script with social media buttons?
- How to Run a jQuery Script after a Javascript Script has Finished in WordPress
- Enqueue script/style with multiple GET parameters
- bootstrap-slider.js by seiyria not working in wordpress
- What is The Best Way to Make Parallax header effect for wordpress theme ?? pure CSS or using JavaScript? [closed]
- WP site makes mobile browser crash for high memory usage
- How react js and other Javascript Technologies works on WordPress plugin?
- When trying to run build script with gutenberg (with SVG import) – Error: Plugin name should be specified
- Smooth Scrolling Animation of Image Between Two Containers (Elementor) Using JavaScript and GSAP
- Why is my JS not working on initial load?
- Javascript localization doesn’t load. How to Internationalize javascript without plugin?