as themeforest require load scripts from wp_head . and the wp_head must be immediately </head>
so how can I call a function with options from php?
I can’t call this function inside the script.js to load from wp_head. I must place this function below the wp_head because I can get jquery work after wp_head loaded
jQuery(document).ready(function(){
//call slider
jQuery('#main-slider').wopeslider({
'height': 960,
'width' : <?php echo empty($slider_options['slider_height']) ? 400 : $slider_options['slider_height'] ;?>
});
...
});
I am not sure what the problem is, but you don’t have to manually echo php variables, use wp_enqueue_script to enqueue script.js, make sure it’s dependency is set to jquery, and then use this function: http://codex.wordpress.org/Function_Reference/wp_localize_script
maybe you’re right , let me try it.
rongcon said
maybe you’re right , let me try it.
he is definitely right, otherwise you will get rejected, and worse – different problems might show up on different systems, also don’t forget to enqueue script specifying which lib the script depends on.
cheers!
SakuraPixel said
rongcon said
maybe you’re right , let me try it.he is definitely right, otherwise you will get rejected, and worse – different problems might show up on different systems, also don’t forget to enqueue script specifying which lib the script depends on.
cheers!
thanks!
I call javascript below the html blocks 
Or you can go with this:
add_action( 'wp_head', 'yourprefix_head_js' );
function yourprefix_head_js(){
?>
<script type="text/javascript">
/* The JavaSript */
</script>
<?php
}
try this..
function slider() {
<script type="text/javascript">
jQuery(document).ready(function(){
//call slider
jQuery('#main-slider').wopeslider({
'height': 960,
'width' : <?php echo empty($slider_options['slider_height']) ? 400 : $slider_options['slider_height'] ;?>
});
...
});
</script>
}
add_action( 'wp_head', 'slider' );
@mabuc
Always add a prefix.
And $slider_options doesn’t exists in there, needs to be defined at the top of the function first.
thanks bros for suggestions 
rongcon said
thanks bros for suggestions![]()
You’re welcome 
