I have reviewed this.

In a sloppy but functional way, I am currently loading a script which is shown only on the front page using this 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.js"></script>
<script type="text/javascript">$.backstretch("wp-content/themes/photoshot/images/home_bg.jpg", {speed: 1000});</script>';?>

In the same way, I attempted to load the same script for a given category:

<?php if ( 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.js"></script>
<script type="text/javascript">$.backstretch("wp-content/themes/photoshot/images/home_bg.jpg", {speed: 1000});</script>'; ?>

However, it does not seem to work. Any suggestions?

2 answers

0
points

Make sure the slug "news" is actually a category slug and is_category() is reserved for archive pages where in_category() is reserved for posts.

WordPress codex

Answered about 6 years ago by VagrantRadio
0
points

made sure news is actually the cat slug.. not sure about the second part of your advice.. :/ ('is_category() is reserved for archive pages where in_category() is reserved for posts')

Answered about 6 years ago by vulgarbulgar
  • This site doesn't follow the traditional forum format and instead takes its style from Stackoverflow and similar sites. Instead of responding like this, in the future you can add a comment to the answer in which you are responding using the 'Add a comment' link. Ktash about 6 years ago