Yeah that’s right. I’m posting something. What a god awful background this theme has.
Over at mortgagesbyjoe.ca, I wanted to load the javascript and css that controls the “accordion” feature that appears only on the front page of the site. There is no point to these loading on any other page of the site. Mortgagesbyjoe is a WordPress powered site that uses the Headway theme framework.
Here is the code I used in my custom_functions.php:
// Load js and css for front page accordion
function load_accordion()
{
if (is_front_page()) { /* If front page */ ?>
<!-- start load front page accordion -->
<script type="text/javascript" src="http://mortgagesbyjoe.ca/wp-content/uploads/headway/template-uploads/js/jquery.accordion.js">
<ink rel="stylesheet" type="text/css" media="screen" href="http://mortgagesbyjoe.ca/wp-content/uploads/headway/template-uploads/css/jquery.accordion.css" />
<!-- end load front page accordion -->
<?php }
}
add_action('wp_head', 'load_accordion');
Yes I used absolute links to the files. Bad. What I should have done, and will do when I’m not feeling lazy is something like:
script src="'.get_bloginfo('url').'custom/js/jquery.accordion.js/" type="text/javascript"
That little .get_bloginfo bit tells the browser to look in the root of your theme folder. You can't have this much fun without breaking a law.