Print string to footer using wp_footer option

add_action('wp_footer','slider_option');

 function slider_option() { 
   $option ="<script>script function data
                    </script>"; 
    echo $option; 
 }

I want to print or you can say insert data in $option variable to footer menu

Any suggestions?

2 Answers
2

Do you have to use a variable for you script?

I have done this in the past and has worked…

// add script to the footer and break out of PHP
function slider_option(){ ?>

<script>script function data</script>

<?php } ?>

add_action('wp_footer','slider_option');

If this does not work make sure you have the footer hook in you themes footer template file.

<?php wp_footer(); ?>

Leave a Comment