0

I saw this Javascript feature tour file today, and was curious how I would go about implementing it on the homepage of a WordPress site.

Ideally, I'd like to add it so it only shows up if and only if a user is on the homepage and have never been there before. I'm new to this though, and I'm not sure how to implement it. I found this previous question but I'm not sure how I would use it in this context. How would I use it on the homepage, and what files would I have to edit?

1 Answer 1

0

You would enqueue it, this is how Javascript is added to WordPress properly. This function would typically go in your theme's functions.php or in a plugin.

function my_scripts_intro() {
     is_front_page(){
         wp_enqueue_script( 'introjs','path to ..intro.js' );
         wp_enqueue_style( 'introcss','path to ..intro.css' );
        }
}

add_action( 'wp_enqueue_scripts', 'my_scripts_intro' );

To determine the state of the visitor you would probably want to use cookies.

ps. This questions is very common please use the search.

2
  • Thanks for the information on enqueuing. If I added this code into the functions.php file, what file would I edit to call it on the homepage?
    – TRBS
    Commented Mar 16, 2013 at 5:54
  • This is what the code above does ....is_front_page ... link
    – Wyck
    Commented Mar 16, 2013 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.