I want to include a slider in the default WordPress theme on the home page. I did manage to get the page to show using <?php if ( is_home() ) { include ('slider.php'); } ?>
but it doesn’t look like it’s loading the jquery script it needs or the style sheet. I know there’s a conflict with scripts and WordPress, I just don’t know how to get it to work.
Sample page is at http://axiomwest.com/
How do you feed in a page with it’s own style sheet and scripts?
You need to have the script in a separate file (normally it would be filename.js; I suppose filename.php would work?).
Then, you need to register and enqueue that script file, using
wp_register_script()
andwp_enqueue_script()
e.g.:
Note that registering the script should happen at
after_setup_theme
, butis_home()
will not be available at this point I don’t think, which is why you need to separate the enqueueing function so that it hooks intowp_head
, by which timeis_home()
is available.UPDATE! What I did was just include the slider I was trying to use. I linked the jquery scripts that page needs via the
<?php bloginfo('template_directory'); ?>
method. I did notice that it takes a couple of seconds to load that portion of the page, but it works. I still think this can be improved, but with time constraints it will have to do. Thanks all for your comments and eagerness to help!