New answers tagged wp-localize-script
Try making the original script a dependency <?php wp_enqueue_script( $handle, $src, 'original_script_handle'); ?>
You have to use the correct handle: wp_localize_script('page_data', 'glr_dt', $gallery_js_data_array); // Edit Your code is also wrong. What do you want to do in this line: 'maxPages' => '$gallery_max_load = $gallery->max_num_pages;' You are assigning a string to maxPages. I guess you want it that way (or similar): 'maxPages' => ...
My need was to set different prices in the session and fetch those in my js script. I am using a jquery session plugin to set and get session, but it wasn't getting session set by php, so I was trying to send variables using wp_localize and set it in the js script. Taking the clue from @Milo, I passed the values using json_encode and set them to session at ...
Top 50 recent answers are included