Note that there are some explanatory texts on larger screens.

plurals
  1. POGlobal Variable in Functions.php Then Use in Javascript (WordPress)
    primarykey
    data
    text
    <p>I'm sorry if this is the wrong place. Actually this has been asked before by another user (although it was not the same question) and it was said that this is a PHP question. Unfortunately I am not good enough in PHP to implement the answer.</p> <p>Here is the [previous question]:<a href="https://wordpress.stackexchange.com/questions/82503/cant-get-options-with-datavariable">https://wordpress.stackexchange.com/questions/82503/cant-get-options-with-datavariable</a></p> <p>I am facing the same problem. In my options, I have a slider's option (animation - fade or slide) and then I want to use the value stored in the option and pass it into Javascript in my function.php.</p> <p>In the option file I have these codes:</p> <pre><code>// Slider animation options $of_options_slider_animation = array( "fade" =&gt; __("Fade", "themename"), "slide" =&gt; __("Slide", "themename") ); </code></pre> <p>and</p> <pre><code>$of_options[] = array( "name" =&gt; __("Slider Animation", "themename"), "desc" =&gt; __("Select the type of animation for the slider.", "themename"), "id" =&gt; "slider_animation", "std" =&gt; "fade", "type" =&gt; "radio", "options" =&gt; $of_options_slider_animation </code></pre> <p>Later I would pass the option into a js block of code in functions.php like so:</p> <pre><code>jQuery('.flexslider').flexslider({ controlNav: true, directionNav: true, prevText: 'Previous', nextText: 'Next', **animation: "&lt;?php echo $smof_data['slider_animation']; ?&gt;",** animationLoop: false // animation: "slide" }); </code></pre> <p>(please notice the bold-ed part)</p> <p>However, as you may predict, it doesn't work.</p> <p>I've tried defining the $smof_data like in the previous question (see link above) but still no luck. Here is what I do:</p> <pre><code>// Fetch options data global $smof_data; $smof_data = of_get_options("slider_animation"); </code></pre> <p>Please help, thanks in advance :)</p> <p>EDIT:</p> <p>SMOF link: <a href="https://github.com/sy4mil/Options-Framework" rel="nofollow noreferrer">https://github.com/sy4mil/Options-Framework</a></p> <p>I am using a blank / starter theme by underscores.me</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload