• Resolved taghaboy

    (@taghaboy)


    I’m working in a WordPress template, and I try to echo the variable “citation_string_to_js” who is in function.php into the JavaScript in my theme footer.php… but it output it empty !

    This is the code i use in function.php :

    add_filter( 'citation_string_to_js', 'return_citation_string_to_js' );
    function return_citation_string_to_js( $arg = '' ) {
    return 'YOUR CONTENTS GOES HERE';
    }

    The JavaScript in Theme template (footer.php) :

    <script type="text/javascript">
    document.getElementById('grid-4').innerHTML = '<? echo apply_filters( 'citation_string_to_js', '' );?>';
    </script>

    what’s wrong ?

    Thanks for helping.

Viewing 2 replies - 1 through 2 (of 2 total)
  • stephencottontail

    (@stephencottontail)

    Your code works fine on my end. Can you temporarily enable debugging and see if any errors appear? Are PHP short open tags enabled by your hosting environment?

    Thread Starter taghaboy

    (@taghaboy)

    Thanks for your reply,
    Your right, i do a mistake 😉 I use .grid-4 instead of #gride-4
    I must to sleep hhhhh
    thanks

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Get php variable in functions.php & echo it in theme template inside JavaScript’ is closed to new replies.