davidpm4
davidpm4

Reputation: 582

wp functions.php flexslider settings

So, I'm a novice at WordPress. I've got this in functions.php which loads the script on every page that gets the footer:

// flexslider custom settings       
add_action('wp_footer', 'aplace_flexslider_settings');

    function aplace_flexslider_settings() { 
?>          
        <script>
            jQuery(document).ready(function($){

              $('.flexslider').flexslider();

         });            
        </script>

Is there a way to customized this so that its called only on the static front page? For example, can I make a custom hook that I'd add_action to and then just get_customHook on the front page? That would disassociate it with the footer, right? I'm so confused...

Upvotes: 0

Views: 121

Answers (1)

levi
levi

Reputation: 25151

Just wrap your function in an if statement:

function aplace_flexslider_settings() { 
    if(is_front_page()) { ?>          
        <script>
            jQuery(document).ready(function($){

              $('.flexslider').flexslider();

         });            
        </script>
<?php } } ?>

Upvotes: 2

Related Questions