You’re not accessing the value correctly. The 2nd argument of wp_localize_script
is the name of a JavaScript object that your data will be added to. In your case it’s wpa_data
. This means that the image_path
is accessed at wpa_data.image_path
:
$(function(){
jQuery(document).ready(function() {
$('#home').backstretch([
wpa_data.image_path+"home-bg-slideshow1.jpg",
wpa_data.image_path+"home-bg-slideshow2.jpg",
wpa_data.image_path+"home-bg-slideshow3.jpg",
], {duration: 2000, fade: 750});
});
})
Related Posts:
- Create Image Uploader for Widget
- How to resize image on client-side before upload?
- Passing PHP Variables to JS using Localize Script
- Using wp_localize_script to store the template url into a variable to use in JS
- How can I output a php value into a JS file within WordPress?
- Ajax random number always the same
- Integrating PHP into Javascript to display map markers with Google API – problem with wp_localize
- How to register javascript variables in wp_localize_script?
- wp_localize_script() and JavaScript namespaces
- Some problems in custom widget
- Show next image in array if page is revisited by same logged user
- Import js variables loaded via wp_localize_script() into js module without global scope connection
- bloginfo url in javascript
- Theme currently showing thumbnails, how to show full size?
- 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
- Validate Uploaded Image using WordPress’ Built-in Functions?
- Get most recent media upload
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- How to make custom total price reactive in navigation
- Adding tawk.to code just before body tag on functions.php file
- How do I fetch all comments per post via WP REST API?
- Deregistering a script in WordPress seems impossible
- Slide in Panel WordPress Post
- Sending jsPDF documents to the server
- IMG src weird behaviour inside a single post loop
- How to prevent those PHP variables from being cached on WordPress?
- Convert all images to PNG on file upload
- Escape post image attachments added to template
- Ajax return code 400
- How can I add an alert (like the old javascript alerts) to my WP page?
- Auto crop images in WordPress
- Display post image with fancybox
- Pass PHP variable to JavaScript without inline JS
- Show post in slider
- Using shipped version of jquery
- How to get media objects
- PHP code to call image Caption, Alternative Text, and Decription?
- Putting PHP variables into javascript [duplicate]
- Bridging TinyMCE js and WordPress PHP?
- Echo URL of large version of Featured Image
- How do I let users upload files to a chosen location?
- Trying to implement Ajax comments in WordPress, getting WP error
- How to test nonce with AJAX – Plugin development
- Change the URL of an image from wp_get_attachment_image_src except in the frontpage
- Get different images for mobile and desktop with php, advanced custom fields without using js and ajax
- 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
- 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?
- How to get specific image in media library with php
- js file in root loading without
- hover image appears below placeholder instead of overlayed
- class click counter save number
- Trigger popup in a php if/else statement
- Slider loading issue
- AJAX request status 200 but no actual “response”
- Button not refreshing page
- Ajax not working es expected (Returns 0)
- add_image_size for header_image
- Use menu link or onClick to set a variable
- Add custom url to featured image
- Get image’s size name from it’s dimension
- Cannot display or echo alt text on featured image
- Recent posts with featured image or fallback image with permalink
- How to select the contents in the text view textrea in wp_editor?
- Creating a Multi-Level Associative Object Using AJAX
- WP functions in .js
- Adding custom directory and PHP files in wordpress
- Best practice for migration friendly images in posts/pages?
- Set the background to a default image if there isn’t a specified “featured image”
- Ajax – Call to undefined function get_option()
- Mass update excerpt
- Populate dropdown with Child Pages based on Parent Page chosen
- remove wp floating submenu in wp dashboard
- How to control WordPress image metadata (using Imagick)?
- 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 complete two other input fields, completed the first
- Status 400 for AJAX POST Request with admin-ajax.php
- How to inject variables into public-facing JS using wp_enqueue_script
- How to pass aa JS variable to PHP?
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- Get the post ID and display the images
- Responsive Header for Phone
- Image upload via FormData API and AJAX is not working ($_FILES always empty)
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- Reprinting tags with all attributes
- JS file work only in index page
- Need Help Fixing My Iframes [closed]
- wp_enqueue_scripts leads to error
- Javascript file is not working on single.php wordpress [closed]
- How to change redirection route to a php page for making it only accessible by logged-in members?
- How to get next image with this code from same post?
- Unread Repeater field IMG alt not working
- Save Search System