Support » Fixing WordPress » Get php variable in functions.php & echo it in theme template inside JavaScript

  • 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)
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.