Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
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 Mar 16 '13 at 5:54
    
This is what the code above does ....is_front_page ... link –  Wyck Mar 16 '13 at 5:55
    
Gotcha. Thanks again. –  TRBS Mar 16 '13 at 5:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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