Hi all.

I have the following code in the header.php of my Wp theme, right below the wp_head code.

<?php 
if ( is_front_page() )
echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="wp-content/custom/jquery.backstretch.min.top.js"></script>
<script type="text/javascript">$.backstretch("wp-content/themes/photoshot/images/home_bg.jpg", {speed: 1000});</script>';

elseif (is_category('news'))
echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="wp-content/custom/jquery.backstretch.min.top.js"></script>
<script type="text/javascript">$.backstretch("wp-content/themes/photoshot/images/about_bg.jpg", {speed: 1000});</script>';
?>

I know it may not be the best practice, but it works (mostly) for now. Anyway, the script loads correctly on the front page of the blog and on all other pages, but for some reason it will not work for a given category (the category slug in my case is 'news').

When I go to the news category, firebug shows that the script is loaded correctly but still, no background image appears.

Any ideas?

Thanks!

2 answers

0
points

Try the full path on the image and use in_category instead of is_category

Answered over 8 years ago by songdogtech
0
points

nada... looking into including the script properly with wp_enqueue_script. hopefully it helps..

Answered over 8 years ago by vulgarbulgar