wp_localize_script it's doesn't work
-
hai,
i’m amateur wordpress developer,
this is my case,
I’m create a theme options SMOF to customize the slider, partly script file .js (for slides), I’ve overridden in header.php.
current speed, i integration in theme options, my changes theme options it’s work, but fitting nav + auto (auto slide). I replace false (in header.php), it doesn’t work. but fitting in its files .js I replace false, it’s work.
i try use wp_localize_script, for speed it’s work. but for nav + auto it’s doesn’t work. i don’t know why ??
this my code for wp_localize :
<?php global $data; $smof = of_get_options(); $speed = $smof['speed']; $arrow = $smof['arrow']; $auto = $smof['auto']; wp_enqueue_script('sunslider', get_template_directory_uri() .'/js/custom.js', true); wp_localize_script('sunslider', 'slider_info', array ( 'auto' => $auto, 'nav' => $arrow, 'speed' => $speed )); ?>
end then, i see source of the page. any this script :
<script type='text/javascript'> /* <![CDATA[ */ var slider_info = {"auto":"0","nav":"0","speed":"505"}; /* ]]> */ </script>
and, i has change for my custom.js. this my script for slider :
jQuery(function () { // Slideshow 4 jQuery(".pic_slider").responsiveSlides({ auto: slider_info.auto, // < this pager: false, nav: slider_info.nav, // < this speed: slider_info.speed, // < this namespace: "callbacks", before: function () { jQuery('.events').append("<li>before event fired.</li>"); }, after: function () { jQuery('.events').append("<li>after event fired.</li>"); } }); });
anyone can help me? please ??
thx before ??
- The topic ‘wp_localize_script it's doesn't work’ is closed to new replies.