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)
- ajaxurl not defined on front end
- 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
- WordPress Enqueue Script Chaos (jQuery & Foundation.js)
- 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
- Check javascript file Proper way in functions.php
- wp_enqueuescript won’t load in footer even with true value set?
- Modifying JS files in Child-theme
- 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?
- Toggle Sidebar Display
- 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?
- Using page-id-{ID} from body_class() in local dev, versus live staging
- Custom theme, contact form 7 & fast secure form doesn’t work
- WP Plugin Running before jQuery
- Javascipt issue on custom theme
- Loading scripts on a single page plants the script in the footer
- WordPress theme resource won’t load over VPN
- Using function from enqueued .js file in theme in plugin?
- How do I implement jPanelMenu?
- getBoundingClientRect() showing different values on load vs scroll
- wordpress script_loader_tag in function.php
- 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
- WordPress core jquery version file not loaded?
- Add a Script button in W3 Total Cache plugin not working due to conflicting jQuery version
- Customizer Image-Picker Preview Not Working
- Correct was to customise theme using get_theme_mod in scripts
- how to add jquery to wordpress
- how can I re-utilize and class on a child theme
- Enqueue javascript that inserts custom php widget into jQuery-constructed div
- Flexslider not working for my custom theme WordPress
- 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?
- wp_enqueue_script causes page to vanish
- How to reuse parts of WordPress site e.g. header, footer, part of header for multiple WordPress sites?
- javascript not loading in wordpress
- bootstrap-slider.js by seiyria not working in wordpress
- WP site makes mobile browser crash for high memory usage
- How react js and other Javascript Technologies works on WordPress plugin?